【问题标题】:flutter button has spacing at the top颤振按钮顶部有间距
【发布时间】:2020-10-13 04:22:00
【问题描述】:
Widget tabTitleDetails = Container(
      margin: EdgeInsets.symmetric(vertical: 8.0),
        decoration: BoxDecoration(
          color: Colors.white,
        
          border: Border.all(
            color: Colors.black,
            width: 8,
          ),
          borderRadius: BorderRadius.circular(12),
        ),
      
  
        child: Column(
          children: <Widget>[
            Container(
              padding: EdgeInsets.all(0.0) ,
              margin:EdgeInsets.all(0.0),
              child: Row(
                children: <Widget>[
                
                  RaisedButton(
                        onPressed: (){},
                        child:new Text('Sell')
                  ),
                      
                ],
              )
            ),
            numDetails
          ],
        )
    
      );

enter image description here

问题: 这段代码运行,屏幕显示按钮与顶部的距离

【问题讨论】:

  • 你知道你在 8px 的顶部设置了对称填充
  • 对不起,我不知道,谢谢你告诉我

标签: flutter button layout


【解决方案1】:

将materialTapTargetSize: MaterialTapTargetSize.shrinkWrap 添加到您的FlatButton。

这是因为 Flutter 的默认按钮尺寸为 48*48,所以如果您的按钮尺寸较小,那么 Flutter 将为它提供填充。您也可以将高度增加到大于 48。这里是Flutter Source。

【讨论】:

  • 非常感谢!!对我很有用。
  • 如果这解决了您的问题,请接受答案。谢谢
猜你喜欢
  • 2020-08-10
  • 2019-05-13
  • 1970-01-01
  • 2019-12-17
  • 1970-01-01
  • 2021-08-15
  • 2020-05-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多