在Flutter 1.22中,我们收到了一个新的OutlinedButton
小部件,用来代替OutlineButton
,但实际上如何使其边界变圆呢? borderSide
和shape
属性不再可用。
最佳答案
您可以使用OutlinedButton.styleFrom
属性:
OutlinedButton(
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(18.0),
),
side: BorderSide(width: 2, color: Colors.green),
),
onPressed: () {},
child: Text('Button'),
)
从源代码 /// All parameters default to null, by default this method returns
/// a [ButtonStyle] that doesn't override anything.
///
/// For example, to override the default shape and outline for an
/// [OutlinedButton], one could write:
///
/// ```dart
/// OutlinedButton(
/// style: OutlinedButton.styleFrom(
/// shape: StadiumBorder(),
/// side: BorderSide(width: 2, color: Colors.green),
/// ),
/// )
/// ```
关于flutter - 问:如何在Flutter中的新OutlinedButton小部件上实现圆角?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/64322596/