【问题标题】:How to give icon value color change in if-else condition in flutter?如何在颤动的if-else条件下赋予图标值颜色变化?
【发布时间】:2020-10-28 20:06:48
【问题描述】:

如何在flutter中改变if-else语句中的图标颜色

Icon(_image == null ? MdiIcons.imageSearch : MdiIcons.checkBold,size: 35)

【问题讨论】:

    标签: android ios flutter dart flutter-layout


    【解决方案1】:

    您可以在图标颜色参数中更改颜色 颜色:_image == null ?Colors.red:Colors.blue

    Icon(_image == null ? MdiIcons.imageSearch : MdiIcons.checkBold,size: 35,color : _image == null ?Colors.red : Colors.blue)
    

    【讨论】:

    • dart 2.12 说无效的常量值
    【解决方案2】:

    使用这个:

    Icon(Icons.add , color: _image == null ? Colors.red : Colors.blue,)
    

    【讨论】:

      猜你喜欢
      • 2021-07-24
      • 2012-10-03
      • 2021-11-17
      • 2013-07-14
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 2015-01-31
      • 2018-09-20
      相关资源
      最近更新 更多