我需要知道是否有可能在flutter小部件中使用三元/如果不使用其他语言。
我正在尝试创建一个buttonCreator小部件,该小部件将使用几个参数,其中一个将是背景。我需要检查小部件是否启用了后台。我所拥有的是这个,但是我不知道如何在真实的Dart代码中使用它。
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')
)
),
);
};
Run Code Online (Sandbox Code Playgroud)