user-interface - Flutter 中的水平按钮组

标签 user-interface flutter dart

我正在尝试使用 flutter 构建一个水平按钮组,但我没有达到预期的效果,我是使用 dart 构建 UI 的新手,我如何调整代码以获得预期的结果?

下面你会看到我目前的进度和想要的结果!

当前行的按钮

//Horizontal buttons row    
            Wrap(                  
              direction: Axis.horizontal,
              children: <Widget>[
                ButtonTheme(
                  minWidth: 40.0,
                  child: RaisedButton(
                    color: Colors.white,
                    onPressed: () {},
                    child: Text("A"),
                  ),
                ),
                ButtonTheme(
                  minWidth: 40.0,
                  child: RaisedButton(
                    color: Colors.white,
                    onPressed: () {},
                    child: Text("B"),
                  ),
                ),
                ButtonTheme(
                  minWidth: 40.0,
                  child: RaisedButton(
                    color: Colors.white,
                    onPressed: () {},
                    child: Text("C"),
                  ),
                ),
                ButtonTheme(
                  minWidth: 40.0,
                  child: RaisedButton(
                    color: Colors.white,
                    onPressed: () {},
                    child: Text("D"),
                  ),
                ),
                ButtonTheme(
                  minWidth: 40.0,
                  child: RaisedButton(
                    color: Colors.white,
                    onPressed: () {},
                    child: Text("E"),
                  ),
                ),
                ButtonTheme(
                  minWidth: 40.0,                     
                  child: RaisedButton(
                    color: Colors.white,
                    onPressed: () {},
                    child: Text("F"),
                  ),
                ),
                ButtonTheme(
                  minWidth: 40.0,
                  child: RaisedButton(
                    color: Colors.white,
                    onPressed: () {},
                    child: Text("G"),
                  ),
                ),                        
              ],
            )

给出的结果: enter image description here

期望的结果 enter image description here

最佳答案

您可以在 Web 和桌面中使用更易于访问且与 tabindex 兼容的 ToggleButtons https://api.flutter.dev/flutter/material/ToggleButtons-class.html

https://www.youtube.com/watch?v=kVEguaQWGAY

关于user-interface - Flutter 中的水平按钮组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57509675/

相关文章:

reactjs - 带 React 的 Material 表 : how to use star rating in the cell?

c# - visual C# 是否有可能比进程运行的进度条有更多的反馈?

flutter - 如何在 Flutter 中启动时调用函数

android - 当我将 MediaQuery.of(context).padding.top 与 appBar 一起使用时,它返回 0.0。这是为什么?

angular - 使用@canActivate的Dart angular2

dart - Flutter动画如何逐渐淡入/淡出

windows - 关闭的窗口保留他们的值(value)观/选择

java - 将输入从 JButton 传递到控制台

flutter - 复选框在对话框中切换

flutter - Flutter如何像书本一样垂直滚动屏幕