简体   繁体   English

Flutter-向 OutlinedButton 小部件添加 Padding

[英]Flutter- Adding Padding to OutlinedButton widget

I have problem adding pad for the OutlinedButton, I have been using OutlineButton and I have decided to OutlinedButton because the button is depreciated.我在为 OutlinedButton 添加焊盘时遇到问题,我一直在使用 OutlineButton,但我决定使用 OutlinedButton,因为该按钮已折旧。 However, the usage of the button is different where the padding parameter is undefined.但是,在未定义填充参数的情况下,按钮的用法有所不同。 I have tried wrapping OutlinedButton in ButtonTheme but it does not have any effect and now I am using Padding as shown in the code example below.我尝试将 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),
                  )),
                )
              ]),
            ])
          ],
        ),

Thanks in advance.提前致谢。

Both OutlinedButton and ElevatedButton have a styleFrom method you can use to set things like padding, color, and shape: OutlinedButton 和 ElevatedButton 都有一个styleFrom方法,可用于设置填充、颜色和形状等内容:

 OutlinedButton(
          child: Text('Padded Button'),
          onPressed: (){
            
          },
          style: OutlinedButton.styleFrom(
            padding: EdgeInsets.all(8),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(16)
            )
          ),
        )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM