我在为 OutlinedButton 添加 pad 时遇到问题,我一直在使用 OutlinedButton,并且我决定使用 OutlinedButton,因为该按钮已折旧。但是,在未定义 padding 参数的情况下,按钮的用法有所不同。我尝试将 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),
)),
)
]),
])
],
),
Run Code Online (Sandbox Code Playgroud)
提前致谢。
OutlinedButton 和 ElevatedButton 都有一个styleFrom方法,您可以使用它来设置填充、颜色和形状等内容:
OutlinedButton(
child: Text('Padded Button'),
onPressed: (){
},
style: OutlinedButton.styleFrom(
padding: EdgeInsets.all(8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16)
)
),
)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6193 次 |
| 最近记录: |