弹奏错误 - 参数类型' motitalStateProperty< roundedRectangleBorder>'可以将分配给参数类型
想要自定义按钮的默认边框半径,但存在以下错误: “参数类型'材料StateProperty'不能分配给参数类型'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)),
)),
),
want to customize the button's default border radius but having the following error:
"The argument type 'MaterialStateProperty' can't be assigned to the parameter type '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)),
)),
),
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需删除材料StateProperty.All(或用以下代码替换您的代码。
Just remove MaterialStateProperty.all( or replace your code with below.
对于类型来说,这很有帮助,如果您想使用,只需添加通用类型即可。 文档
That's helpful for the types, if you want to use you only have to add the generic type. Documentation