我正在尝试实现一个没有边距的按钮。
我的代码是:
@override
Widget build(BuildContext context) {
return new AppState(
child: new Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFF031e39),
title: Text("MY APP"),
),
body:
ButtonTheme(
buttonColor: Color(0xFF031e39),
minWidth: double.infinity,
child: FlatButton(
color: Color(0xFF81A483),
onPressed: () {
launchSearch();
},
child: Text('Search',style: TextStyle(color: Colors.white),),
),
)
),
);
}
结果是:
我尝试了所有不同的方法,但我找不到解决方案,所以按钮没有边距。
如果我在列中的按钮顶部放置一个小部件,我会得到相同的结果:
我怎样才能拥有没有边距的 FlatButton?
最佳答案
根据source .看起来 Flutter 会填充小于目标点击尺寸 (48 x 48) 的按钮,您可以通过以下方式绕过它:
- 使您的按钮高度大于或等于 48
或
- 将
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
添加到您的FlatButton
。
关于android - 没有边距的 flutter 添加按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53744731/