abh*_*ngh 6 android ios hybrid-mobile-app flutter flutter-layout
我试过在容器内嵌套切换按钮并给它一个自定义宽度但是它没有用
ToggleButtons(
borderColor: Colors.deepOrangeAccent[100],
fillColor: Colors.deepOrange[100],
borderRadius: BorderRadius.circular(8.0),
selectedBorderColor: Colors.deepOrange,
children: <Widget>[
new Row(children: <Widget>[new Icon(Icons.whatshot,size: 16.0,color: Colors.red,),new SizedBox(width: 4.0,), new Text("HOT",style: TextStyle(color: Colors.red),)],),
new Row(children: <Widget>[new Icon(Icons.invert_colors,size: 16.0,color: Colors.yellow[800],),new SizedBox(width: 4.0,), new Text("WARM",style: TextStyle(color: Colors.yellow[800]))],),
new Row(children: <Widget>[new Icon(Icons.ac_unit,size: 16.0,color: Colors.blue,),new SizedBox(width: 4.0,), new Text("COLD",style: TextStyle(color: Colors.blue))],),
],
onPressed: (int index) {
setState(() {
EnquiryModel.instance.setStatus(index.toString());
for (int buttonIndex = 0; buttonIndex < isSelected.length; buttonIndex++) {
if (buttonIndex == index) {
isSelected[buttonIndex] = true;
} else {
isSelected[buttonIndex] = false;
}
}
});
},
isSelected: isSelected,
)
Run Code Online (Sandbox Code Playgroud)
小智 19
我知道我的答案不是很好的解决方案,但它有效。
children: <Widget>[
Container(width: (MediaQuery.of(context).size.width - 36)/3, child: new Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[new Icon(Icons.whatshot,size: 16.0,color: Colors.red,),new SizedBox(width: 4.0,), new Text("HOT",style: TextStyle(color: Colors.red),)],)),
Container(width: (MediaQuery.of(context).size.width - 36)/3, child: new Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[new Icon(Icons.invert_colors,size: 16.0,color: Colors.yellow[800],),new SizedBox(width: 4.0,), new Text("WARM",style: TextStyle(color: Colors.yellow[800]))],)),
Container(width: (MediaQuery.of(context).size.width - 36)/3, child: new Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[new Icon(Icons.ac_unit,size: 16.0,color: Colors.blue,),new SizedBox(width: 4.0,), new Text("COLD",style: TextStyle(color: Colors.blue))],)),
]
Run Code Online (Sandbox Code Playgroud)
我减少了 36,因为我的页面有页面填充。您可以通过设置更改它。
这里的结果:
| 归档时间: |
|
| 查看次数: |
5245 次 |
| 最近记录: |