gpt4 book ai didi

flutter - 如何在 Flutter 中的新 OutlinedButton 小部件上实现圆角?

转载 作者:行者123 更新时间:2023-12-03 03:14:01 32 4
gpt4 key购买 nike

在 Flutter 1.22 中,我们收到了一个新的小部件 OutlinedButton用来代替OutlineButton但是我们如何才能真正使它的边框变圆? borderSideshape属性不再可用。

最佳答案

您可以使用 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com