如何更改此 flutter Material 按钮的大小?
How can I change the size of this flutter Material Button?
我想更改按钮的大小,通过减小垂直大小使其有点压扁。
我写的当前代码是这样的:
Padding(
padding: const EdgeInsets.all(8),
child: Material(
color: Color(0xFF3E4685),
borderRadius: BorderRadius.circular(20),
elevation: 6,
child: MaterialButton(
height: 0,
onPressed: () {},
padding: EdgeInsets.symmetric(vertical: 0),
child: Icon(
Icons.arrow_right_alt_sharp,
size: 50,
color: Colors.white,
),
),
),
)
输出是这样的:
Button
我希望它能被压扁一点,垂直高度更小,我试过使用高度 属性 但它不起作用。
试试这个
SizedBox(
width: 150,
height: 150,
child: Material(
color: Color(0xFF3E4685),
borderRadius: BorderRadius.circular(20),
elevation: 6,
child: MaterialButton(
height: 0,
onPressed: () {},
padding: EdgeInsets.symmetric(vertical: 0),
child: Icon(
Icons.arrow_right_alt_sharp,
size: 50,
color: Colors.white,
),
),
),
或者您可以使用 ButtonTheme
ButtonTheme(
minWidth: 200.0,
height: 100.0,
child: YourButton
),
我想更改按钮的大小,通过减小垂直大小使其有点压扁。 我写的当前代码是这样的:
Padding(
padding: const EdgeInsets.all(8),
child: Material(
color: Color(0xFF3E4685),
borderRadius: BorderRadius.circular(20),
elevation: 6,
child: MaterialButton(
height: 0,
onPressed: () {},
padding: EdgeInsets.symmetric(vertical: 0),
child: Icon(
Icons.arrow_right_alt_sharp,
size: 50,
color: Colors.white,
),
),
),
)
输出是这样的: Button
我希望它能被压扁一点,垂直高度更小,我试过使用高度 属性 但它不起作用。
试试这个
SizedBox(
width: 150,
height: 150,
child: Material(
color: Color(0xFF3E4685),
borderRadius: BorderRadius.circular(20),
elevation: 6,
child: MaterialButton(
height: 0,
onPressed: () {},
padding: EdgeInsets.symmetric(vertical: 0),
child: Icon(
Icons.arrow_right_alt_sharp,
size: 50,
color: Colors.white,
),
),
),
或者您可以使用 ButtonTheme
ButtonTheme(
minWidth: 200.0,
height: 100.0,
child: YourButton
),