这是一个愚蠢的问题,但我是 Flutter 的新手。所以我希望你们能帮我解决这个问题。有没有办法在 flutter 中更改按钮的大小?
长方形:
OutlineButton(
child: Text(forgot_password, style: TextStyle(color: colorWhite)),
borderSide: BorderSide(
color: colorWhite,
style: BorderStyle.none,
width: 0.8,
),
onPressed: () {},
),
圆形:
OutlineButton(
onPressed: () {},
child: Icon(
FontAwesomeIcons.google,
color: colorWhite,
size: 20.0,
),
shape: CircleBorder(),
borderSide: BorderSide(
color: colorWhite,
style: BorderStyle.solid,
width: 1,
),
),
最佳答案
您可以使用“ButtonTheme”来改变按钮的大小,如下所示:
For Rectangular shape:
ButtonTheme(
minWidth: 200.0,
height: 100.0,
child: OutlineButton(
child: Text('forgot_password', style: TextStyle(color: Colors.green)),
borderSide: BorderSide(
color: Colors.amber,
style: BorderStyle.solid,
width: 1.8,
),
onPressed: () {},
),
),
For Circular shape:
ButtonTheme(
minWidth: 200.0,
height: 100.0,
child: OutlineButton(
onPressed: () {},
child: Icon(
Icons.screen_lock_portrait,
color: Colors.redAccent,
size: 40.0,
),
shape: CircleBorder(),
borderSide: BorderSide(
color: Colors.blue,
style: BorderStyle.solid,
width: 1,
),
),
)
您还可以使用 Container 和 SizedBox,如下所示:
Container
Container(
width: 200.0,
height: 100.0,
child: OutlineButton(
child: Text('Login', style: TextStyle(color: Colors.green)),
borderSide: BorderSide(
color: Colors.amber,
style: BorderStyle.solid,
width: 1.8,
),
onPressed: () {},
),
),
SizedBox
SizedBox(
width: 200.0,
height: 100.0,
child: OutlineButton(
child: Text('Login', style: TextStyle(color: Colors.green)),
borderSide: BorderSide(
color: Colors.amber,
style: BorderStyle.solid,
width: 1.8,
),
onPressed: () {},
),
),
关于dart - 如何更改大纲按钮大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55989335/