Dart 颤振,如何使我的原材料按钮大,更紧密地包装在一起。
我有一些代码可以创建7个圆形的原材料按钮。然而,我似乎无法改变圆圈的大小,也无法将它们放在一起 Page.dartDart 颤振,如何使我的原材料按钮大,更紧密地包装在一起。,dart,flutter,Dart,Flutter,我有一些代码可以创建7个圆形的原材料按钮。然而,我似乎无法改变圆圈的大小,也无法将它们放在一起 Page.dart Row( children: <Widget>[ new ThemeButton(Colors.red, () => print("red")), new ThemeButton(Colors.orange, () => print("orange")), new ThemeButton(Colors.yellow, () =&g
Row(
children: <Widget>[
new ThemeButton(Colors.red, () => print("red")),
new ThemeButton(Colors.orange, () => print("orange")),
new ThemeButton(Colors.yellow, () => print("yellow")),
new ThemeButton(Colors.green, () => print("green")),
new ThemeButton(Colors.blue, () => print("blue")),
new ThemeButton(Colors.indigo, () => print("pink")),
new ThemeButton(Colors.purple, () => print("purple")),
],
),
@override
Widget build(BuildContext context) {
return RawMaterialButton (
shape: CircleBorder(),
fillColor: _themeColour,
elevation: 0.0,
highlightElevation: 0.0,
onPressed: () => _onPressed(),
splashColor: Colors.transparent,
highlightColor: Colors.transparent,
);
}
显示:
所以我面临的三个问题都是关于元素的大小和定位
RawMaterialButton
,应该有一个padding
属性,您可以在构造函数中设置,这是此类组件的典型属性。尝试在按钮的构造函数中更新填充值,而不是添加新的小部件。为了清楚起见,请尝试将填充设置为EdgeInsets.all(0.0)
要进一步调整大小,您可以开始查看行
,特别是MainAxisSize
,或者将它们包装在灵活的
小部件系列的变体中。很遗憾,更改padding属性对我不起作用。但是,像本例中那样更改约束参数非常有效:
RawMaterialButton(
constraints: BoxConstraints.tight(Size(36, 36)),
onPressed: null,
child: Icon(Icons.trending_up, size: 18),
shape: new CircleBorder(),
elevation: 0.0,
fillColor: Color.fromARGB(255, 240, 240, 240),
),
希望有帮助