【问题标题】:custom color for RaisedButton FlutterRaisedButton Flutter 的自定义颜色
【发布时间】:2020-04-15 10:00:01
【问题描述】:

当我使用这个库为 RaisedButton 添加自定义颜色时 https://pub.dev/packages/color


    return new Padding(
        padding: EdgeInsets.fromLTRB(10.0, 180.0, 10.0, 0.0),
        child: SizedBox(
          height: 60.0,
          child: new RaisedButton(
            elevation: 5.0,
            // color: Colors.greenAccent[100],
            color:rgbColor,
            // color: Color(0xffFF1744),
            child: new Text( 'Sign in',
                style: new TextStyle(fontSize: 20.0,color:Colors.black,fontWeight:FontWeight.w400)),
            onPressed: () => {

            },
          ) 

它给了我这个错误

The argument type 'Color (where Color is defined in /Users/abeer/flutter/.pub-cache/hosted/pub.dartlang.org/color-2.1.1/lib/color.dart)' can't be assigned to the parameter type 'Color (where Color is defined in /Users/abeer/flutter/bin/cache/pkg/sky_engine/lib/ui/painting.dart)

【问题讨论】:

    标签: flutter


    【解决方案1】:

    你为什么要使用颜色库中的 rbgColor,你可以简单地使用

    Color.fromRGBO(r, g, b, opacity)
    

    从 rgb 定义你想要的颜色。

    【讨论】:

      【解决方案2】:

      与括号一起使用

      Colors. black[50]
      

      检查问题https://github.com/flutter/flutter/issues/15658

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-11-24
        • 2019-04-30
        • 2020-08-18
        • 2020-07-10
        • 2019-04-19
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多