[英]How to give Rounded Border to Elevated Button in flutter?
As RaisedButton
and OutlineButton
are deprecated, the flutter team introduces a new ElevatedButton
.由于RaisedButton
和OutlineButton
已弃用,flutter 团队引入了一个新的ElevatedButton
。 But I don't know how to make ElevatedButton's border rounded like the below image.但我不知道如何使 ElevatedButton 的边框像下图那样变圆。
ElevatedButton(
onPressed: () {},
child: Text('Testing'),
),
You could do something like this:你可以这样做:
ElevatedButton(
onPressed: () {},
style: ElevatedButton.styleFrom(
shape: new RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(30.0),
),
),
child: Text(' Elevated Button')
)
ElevatedButton(
style: ButtonStyle(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(color: Colors.green)),
),
),
onPressed: () {},
child: Text('test'),
)
This is how you can use new Ele Button这就是你如何使用新的 Ele Button
ElevatedButtonThemeData(
style: ButtonStyle(
shape: MaterialStateProperty.resolveWith<OutlinedBorder>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return ContinuousRectangleBorder(borderRadius: BorderRadius.circular(10));
}
return ContinuousRectangleBorder(borderRadius: BorderRadius.circular(10)); //CHoose any shape you want
},
),
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return greyColor;
}
return selectedPrimaryColor;
},
),
foregroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
if (states.contains(MaterialState.disabled)) {
return Colors.black;
}
return selectedPrimaryColor;
},
),
),
),
As RaisedButton
and OutlineButton
are deprecated, the flutter team introduces a new ElevatedButton
.由于RaisedButton
和OutlineButton
已弃用,flutter 团队引入了新的ElevatedButton
。 But I don't know how to make ElevatedButton's border rounded like the below image.但我不知道如何使 ElevatedButton 的边框像下图那样圆润。
ElevatedButton(
onPressed: () {},
child: Text('Testing'),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.