簡體   English   中英

Flutter-向 OutlinedButton 小部件添加 Padding

[英]Flutter- Adding Padding to OutlinedButton widget

我在為 OutlinedButton 添加焊盤時遇到問題,我一直在使用 OutlineButton,但我決定使用 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)
            )
          ),
        )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM