【问题标题】:Flutter Icon Button Speed Dial颤振图标按钮快速拨号
【发布时间】:2020-09-09 02:04:35
【问题描述】:

是否存在可以与常规按钮或任何 onclick 事件一起使用的快速拨号小部件?我发现this 小部件与FloatingActionButton 配合得很好,但我需要一些可以与IconButton 或RaisedButton 配合使用的东西。我尝试在容器内使用 SpeedDial 小部件,如下所示:

Container(
                  child: SpeedDial(
                    overlayOpacity: 0.2,
                    animatedIcon: AnimatedIcons.menu_close,
                    children: [
                      SpeedDialChild(
                        child: Icon(Icons.ac_unit),
                        label: 'Second',
                        onTap: () => print('SECOND'),
                      ),
                      SpeedDialChild(
                        child: Icon(Icons.accessibility),
                        backgroundColor: Colors.red,
                        label: 'First',
                        labelStyle: TextStyle(fontSize: 18.0),
                        onTap: () => print('FIRST'),
                      ),
                    ],
                  ),
                ),

但不幸的是,没有运气。我在右边得到一个无穷大的像素。

【问题讨论】:

    标签: flutter dart widget


    【解决方案1】:

    请在右侧和底部使用填充。检查下面的代码。您需要为Text设置一个TextStyle,您还需要为您的孩子使用手动高度和宽度。

    Padding(
          padding: const EdgeInsets.fromLTRB(0, 0, 20, 20),
          child: Container(
            child: SpeedDial(
              overlayOpacity: 0.2,
              animatedIcon: AnimatedIcons.menu_close,
              children: [
                SpeedDialChild(
                  child: Icon(Icons.ac_unit),
                  label: 'Second',
                  onTap: () => print('SECOND'),
                ),
                SpeedDialChild(
                  child: Icon(Icons.accessibility),
                  backgroundColor: Colors.red,
                  label: 'First',
                  labelStyle: TextStyle(fontSize: 18.0),
                  onTap: () => print('FIRST'),
                ),
              ],
            ),
          ),
        )
    

    【讨论】:

    • 关于孩子身高和宽度的问题。您是在谈论 SpeedDialChild 吗?
    • 不,在父级中使用
    猜你喜欢
    • 2020-05-07
    • 2022-06-24
    • 1970-01-01
    • 2021-07-05
    • 2019-12-21
    • 2014-08-07
    • 1970-01-01
    • 1970-01-01
    • 2021-08-24
    相关资源
    最近更新 更多