我正在开发Flutter中的一个应用程序,我想使用ButtonBar。然而,当试图让孩子使用空间时,按钮只使用最小的空间
Padding(
padding: const EdgeInsets.all(8.0),
child: ButtonBar(
mainAxisSize: MainAxisSize.max,
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text('Save'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => OtpPage()));
},
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ButtonBar(
mainAxisSize: MainAxisSize.max,
alignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text('Save'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => OtpPage()));
},
),
],
),
),

你知道怎么让按钮利用更多的空间吗?
发布于 2019-06-09 03:39:08
可以使用ButtonTheme属性编辑按钮大小
Raised buttons have a minimum size of 88.0 by 36.0 which can be overridden with ButtonTheme.
第二,
您可以尝试使用Expanded小部件包装按钮
Padding(
padding: const EdgeInsets.all(8.0),
child: ButtonBar(
mainAxisSize: MainAxisSize.max,
alignment: MainAxisAlignment.center,
children: <Widget>[
Expanded(
child: RaisedButton(
child: Text('Save'),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) => OtpPage()));
},
),
),
],
),
),https://stackoverflow.com/questions/56509196
复制相似问题