Flutter中的水平按钮组

Tho*_* V. 6 user-interface dart flutter

我正在尝试使用 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"),
                  ),
                ),                        
              ],
            )
Run Code Online (Sandbox Code Playgroud)

给出的结果: 在此输入图像描述

期望的结果 在此输入图像描述

Tho*_* V. 8

我是这样做的:

Widget specialCharsPanel() {
  return Container(
    child: Material(
      elevation: 4.0,
      borderRadius: BorderRadius.all(Radius.circular(6.0)),
      child: Wrap( 
        direction: Axis.horizontal,                    
        children: <Widget>[
          SpecialChar("A"),
          SpecialChar("B"),
          SpecialChar("C"),
          SpecialChar("D"),
          SpecialChar("E"),
          SpecialChar("F"),
          SpecialChar("G"),                 
        ],
      ),
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)


Mau*_*sky 8

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

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