在 Flutter 1.22 中,我们收到了一个新的小部件 OutlinedButton
用来代替OutlineButton
但是我们如何才能真正使它的边框变圆? borderSide
和 shape
属性不再可用。
最佳答案
您可以使用 OutlinedButton.styleFrom
属性(property):
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/