想要自定义按钮的默认边框半径,但出现以下错误:“无法将参数类型'MaterialStateProperty'指派给参数类型'OutlinedBorder'”
Padding(
padding: const EdgeInsets.all(20.0),
child: ElevatedButton(
style: ElevatedButton.styleFrom(
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0))),
elevation: 0,
primary: Colors.white,
minimumSize: const Size.fromHeight(50)),
onPressed: () {
Navigator.pushNamed(context, '/home');
// Navigator.of(context).pushReplacementNamed('/home');
},
child: const Text(
"Start",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 18,
color: Color.fromRGBO(86, 96, 49, 1)),
)),
),
3条答案
按热度按时间yiytaume1#
只需删除MaterialStateProperty.all(或者用下面的代码替换您的代码。
hmae6n7t2#
如果您不想避免,只需添加泛型类型,这对键入很有帮助。Documentation
高架按钮(样式:按钮样式(背景颜色:所有(Colors.red),形状:材料状态属性。所有(常量圆角矩形边界(边界半径:BorderRadius.all(半径.圆形(8)),),)),子项:const Text('使用Google登录'),onPressed:(){},);
yuvru6vn3#
这对类型很有帮助,如果你想使用,你只需要添加泛型类型。Documentation