Flutter FlatButton子项未在按钮内居中
我有一个小部件,显示带有图标的文本和平面按钮。 问题是图标没有在按钮内居中。 以下是我使用的代码:Flutter FlatButton子项未在按钮内居中,flutter,dart,Flutter,Dart,我有一个小部件,显示带有图标的文本和平面按钮。 问题是图标没有在按钮内居中。 以下是我使用的代码: child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: <Widget>[ Text("Text", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),), Conta
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text("Text", style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold),),
Container(
color: Colors.lightBlue,
width: 40.0,
child: FlatButton(onPressed: () {},
child: Icon(Icons.edit, size: 20.0, color: Colors.white,),
shape: CircleBorder(),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
)
],
)
子项:行(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
文本(“文本”,样式:TextStyle(颜色:Colors.white,fontwweight:fontwweight.bold)),
容器(
颜色:颜色。浅蓝色,
宽度:40.0,
子项:FlatButton(按下时:(){},
子项:图标(Icons.edit,大小:20.0,颜色:Colors.white,),
形状:CircleBorder(),
MaterialTargetSize:MaterialTargetSize.shrinkWrap,
),
)
],
)
您好您应该使用其他类型的按钮,例如:
IconButton(
color: Colors.lightBlue,
icon: Icon(Icons.edit, size: 20.0, color: Colors.white,),
onPressed: () { },
),
有关更多按钮,请访问官方网站:
在
FlatButton上有一个默认的填充
将其设置为EdgeInsets.zero
像这样
FlatButton(
padding: EdgeInsets.zero,
onPressed: (){},
child: Icon(Icons.edit)
)