flutter - RoundedRectangleBorder 不适用于 Container 小部件
问题描述
我需要制作 Container edge circle 以及如何在尝试 RoundedRectangleBorder 时显示错误
Container(
width: 100,height: 100,
margin: EdgeInsets.all(10.0),
decoration: BoxDecoration(
color: Colors.orange,
shape: RoundedRectangleBorder(
borderRadius: new BorderRadius.circular(18.0),
)
),
),
解决方案
这个错误表明,
参数类型
RoundedRectangleBorder
不能分配给参数类型BoxShape
所以如果你想使用RoundedRectangleBorder
那么你必须在shape
参数内部使用它,
Container(
width: 100,height: 100,
margin: EdgeInsets.all(10.0),
decoration: ShapeDecoration(
color: Colors.orange,
shape: RoundedRectangleBorder( // <--- use this
borderRadius: BorderRadius.all(
Radius.circular(10),
),
),
),
),
输出,
@Anil Chauhan 的方法也是正确的,因此您也可以使用它。
推荐阅读
- angularjs - 如何解决 Angular 7 和 mvc 中的路由问题?
- php - 如何使用 PHP 和 MYSQL 将数据插入到两个不同的表中
- jquery - html() 和 val() 在 chrome 与 IE 中的用法
- javascript - 是否可以有条件地在 Javascript 中赋值?
- php - 类 'PHPMailer\PHPMailer\PHPMailer' 未在
- android - Android Jetpack导航,另一个主机片段内的主机片段
- java - 当动态参数是字符串类型时如何删除''?
- angular - Y轴刻度标签的动态标签字符串在chart.js(Angular-4)中没有变化
- android - CameraKitView 库未使用 Kotlin 进行初始化
- wordpress - 自定义管理页面 - WordPress