Flutter-向 OutlinedButton 小部件添加填充
Flutter- Adding Padding to OutlinedButton widget
我在为 OutlinedButton 添加 pad 时遇到问题,我一直在使用 OutlinedButton,但我决定使用 OutlinedButton,因为该按钮已过时。但是,在未定义填充参数的情况下,按钮的用法不同。我曾尝试将 OutlinedButton 包装在 ButtonTheme 中,但它没有任何效果,现在我正在使用 Padding,如下面的代码示例所示。
new Column(children: [
new Row(children: [
//5th row
new Expanded(
child: Padding(
child: new OutlinedButton(
child: new Text(
"Main Page",
style: TextStyle(
fontFamily: 'NotoSans',
fontSize: 20.0,
fontWeight: FontWeight.w400),
),
onPressed: () {
Navigator.of(context).push(_gotoMainPage());
},
padding: EdgeInsets.all(20),
)),
)
]),
])
],
),
提前致谢。
OutlinedButton 和 ElevatedButton 都有一个 styleFrom 方法,您可以使用它来设置填充、颜色和形状等内容:
OutlinedButton(
child: Text('Padded Button'),
onPressed: (){
},
style: OutlinedButton.styleFrom(
padding: EdgeInsets.all(8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)
)
),
)
我在为 OutlinedButton 添加 pad 时遇到问题,我一直在使用 OutlinedButton,但我决定使用 OutlinedButton,因为该按钮已过时。但是,在未定义填充参数的情况下,按钮的用法不同。我曾尝试将 OutlinedButton 包装在 ButtonTheme 中,但它没有任何效果,现在我正在使用 Padding,如下面的代码示例所示。
new Column(children: [
new Row(children: [
//5th row
new Expanded(
child: Padding(
child: new OutlinedButton(
child: new Text(
"Main Page",
style: TextStyle(
fontFamily: 'NotoSans',
fontSize: 20.0,
fontWeight: FontWeight.w400),
),
onPressed: () {
Navigator.of(context).push(_gotoMainPage());
},
padding: EdgeInsets.all(20),
)),
)
]),
])
],
),
提前致谢。
OutlinedButton 和 ElevatedButton 都有一个 styleFrom 方法,您可以使用它来设置填充、颜色和形状等内容:
OutlinedButton(
child: Text('Padded Button'),
onPressed: (){
},
style: OutlinedButton.styleFrom(
padding: EdgeInsets.all(8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)
)
),
)