我需要知道是否有可能在flutter小部件中使用三元/ if else .
我正在尝试创建一个buttonCreator小部件,它将采用一些参数,其中一个将是背景 . 我需要检查小部件是否启用了后台 . 我有这个,但我不知道如何在真正的飞镖码中使用它 .
Container buildButton(String text, bool bg){
return new Container(
decoration: new BoxDecoration(
border: new Border.all(color: Colors.white),
if (bg != true ? color: Colors.white : '')
),
padding: new EdgeInsets.all(15.0),
margin: new EdgeInsets.symmetric(horizontal: 10.0, vertical: 5.0),
child: new Center(
child: new Text(
text, style: new TextStyle(color: Colors.white, fontFamily: 'Monsterrat')
)
),
);
};
1 回答
我认为这是你的问题实际上是什么?