在卡片中定位按钮。扑

Ped*_*ira 5 dart flutter

我在 Flutter 中在卡片中放置 2 个按钮时遇到了一些麻烦。我有这个:
前

但我想要这个:
后

我这张卡按钮的代码是:

new ButtonTheme.bar(
    child: new ButtonBar(
      alignment: MainAxisAlignment.start,
      children: <Widget>[
        Row(
          children: <Widget>[
            Column(
              children: <Widget>[
                new FlatButton(
                  child: Icon(
                    Icons.share,
                    color: Colors.white,
                  ),
                  color: Color.fromRGBO(68, 153, 213, 1.0),
                  shape: CircleBorder(),
                  onPressed: () {
                    Share.share(
                      data[index]["link"],
                    );
                  },
                ),
              ],
            ),
            Column(
              children: <Widget>[
                FlatButton(
                  color:
                  Color.fromRGBO(161, 108, 164, 1.0),
                  child: const Text('Read Article'),
                  shape: new RoundedRectangleBorder(
                      borderRadius:
                      new BorderRadius.circular(
                          30.0)),
                  textColor: Colors.white,
                  onPressed: () {
                    launch(data[index]["link"],
                        forceWebView: false);
                  },
                ),
              ],

            )
          ],
        ),

      ],
    ),
Run Code Online (Sandbox Code Playgroud)

Rao*_*che 7

文档

ButtonBar.children : 水平排列的按钮

我认为你做了很多不必要的事情,为了得到结果,只需将按钮放在里面,ButtonBar而不需要额外的布局小部件,比如RowColumn

在此处输入图片说明

这是代码:

ButtonTheme.bar(
          child: new ButtonBar(
            alignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              FlatButton(
                child: Icon(
                  Icons.share,
                  color: Colors.white,
                ),
                color: Color.fromRGBO(68, 153, 213, 1.0),
                shape: CircleBorder(),
                onPressed: () {},
              ),
              FlatButton(
                color: Color.fromRGBO(161, 108, 164, 1.0),
                child: const Text('Read Article'),
                shape: new RoundedRectangleBorder(
                    borderRadius: new BorderRadius.circular(30.0)),
                textColor: Colors.white,
                onPressed: () {},
              ),
            ],
          ),
        ),
Run Code Online (Sandbox Code Playgroud)


Rém*_*let 5

alignment您可以在您的ButtonBar或上使用不同的Row

alignment: MainAxisAlignment.spaceBetween
Run Code Online (Sandbox Code Playgroud)