Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Dart 颤振,如何使我的原材料按钮大,更紧密地包装在一起。_Dart_Flutter - Fatal编程技术网

Dart 颤振,如何使我的原材料按钮大,更紧密地包装在一起。

Dart 颤振,如何使我的原材料按钮大,更紧密地包装在一起。,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

我有一些代码可以创建7个圆形的原材料按钮。然而,我似乎无法改变圆圈的大小,也无法将它们放在一起

Page.dart

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,
  );
}
显示:

所以我面临的三个问题都是关于元素的大小和定位

  • 圆圈太小,我不喜欢
  • 圆圈周围的空间太宽了
  • 我可以在圆圈外单击,但它仍会注册单击
  • 我已经查看了“原材料”按钮的参数,看不出可以更改什么。添加填充小部件并将其设置为0没有帮助。

    根据for
    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),
    ),
    
    希望有帮助