我刚刚更新了Ffltter中的代码,使用TextButton而不是旧的FlatButton
.不过,我想不出如何设置按钮的宽度和高度.
我有两个问题.第一个是我现在有了这个图标按钮:
TextButton.icon(
label: Container(),
style: TextButton.styleFrom(padding: EdgeInsets.all(0),
backgroundColor: Colors.black26),
icon: Icon(Icons.share, color: Theme.of(context).primaryColor),
onPressed: () {}),
我想不出怎么go 掉左右两边的垫子.虽然我确实将样式内部的填充设置为零.
我的第二个问题是我有一个像这样的按钮:
ButtonTheme(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
height: 10,
minWidth: 15,
padding: EdgeInsets.only(top: 5, bottom: 5, right: 5, left: 5),
child: FlatButton(
color: Colors.white.withOpacity(0.9),
child: <MyChild>,
onPressed: () {},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
side: BorderSide(
color: condition
? Theme.of(context).primaryColor
: widget.color != null
? widget.color
: Colors.black54,
width: 0.5)),
));
}
现在我将代码更新为:
OutlinedButton(
style: OutlinedButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
padding: EdgeInsets.only(top: 0, bottom: 0, right: 5, left: 5),
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
side: BorderSide(
width: 0.5,
color: condition
? Theme.of(context).primaryColor
: widget.color != null
? widget.color
: Colors.black54),
primary: Colors.white.withOpacity(0.9),
),
child: <MyChild>,
onPressed: () {})
But it looks like this now: The padding on top/bottom is too much but I can't figure out how to minimize it.
有什么建议吗?非常感谢.
Edit:我try 使用OutlinedButtonTheme,但这不允许我设置高度等.