如何将FlatButton
放入带有圆形边框的按钮?我使用RoundedRectangleBorder
的圆形边框形状,但不知何故需要为边框着色。
new FlatButton(
child: new Text("Button text),
onPressed: null,
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0))
)
答案 0 :(得分:38)
使用OutlineButton
代替FlatButton
。
new OutlineButton(
child: new Text("Button text"),
onPressed: null,
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(30.0))
)
答案 1 :(得分:7)
使用StadiumBorder
形状
OutlineButton(
onPressed: () {},
child: Text("Follow"),
borderSide: BorderSide(color: Colors.blue),
shape: StadiumBorder(),
)
答案 2 :(得分:6)
new OutlineButton(
child: new Text("blue outline") ,
borderSide: BorderSide(color: Colors.blue),
),
// this property adds outline border color
答案 3 :(得分:2)
要实现带有边框颜色的圆角边框按钮,请使用此
OutlineButton(
child: new Text("Button Text"),borderSide: BorderSide(color: Colors.blue),
onPressed: null,
shape: new RoundedRectangleBorder(borderRadius: new BorderRadius.circular(20.0))
),
答案 4 :(得分:1)
如果您不想使用OutlineButton
并希望坚持使用普通RaisedButton
,则可以将按钮包裹在ClipRRect
或ClipOval
中,如下所示:
ClipRRect(
borderRadius: BorderRadius.circular(40),
child: RaisedButton(
child: Text("Button"),
onPressed: () {},
),
),
答案 5 :(得分:0)
所以我确实使用了这样的完整样式和边框颜色:
new OutlineButton(
shape: StadiumBorder(),
textColor: Colors.blue,
child: Text('Button Text'),
borderSide: BorderSide(
color: Colors.blue, style: BorderStyle.solid,
width: 1),
onPressed: () {},
)
答案 6 :(得分:0)
FlatButton(
onPressed: null,
child: Text('Button', style: TextStyle(
color: Colors.blue
)
),
textColor: MyColor.white,
shape: RoundedRectangleBorder(side: BorderSide(
color: Colors.blue,
width: 1,
style: BorderStyle.solid
), borderRadius: BorderRadius.circular(50)),
)