我刚刚在 Flutter 中更新了我的代码以使用 TextButton 而不是 old 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: () {}),
Run Code Online (Sandbox Code Playgroud)
我不知道如何摆脱左侧和右侧的填充。虽然我确实将样式内的填充设置为零。
我的第二个问题是我有一个这样的按钮:
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)),
));
}
Run Code Online (Sandbox Code Playgroud)
现在我将代码更新为:
OutlinedButton(
style: OutlinedButton.styleFrom(
tapTargetSize: …Run Code Online (Sandbox Code Playgroud) flutter ×1