小编Kas*_*lar的帖子

“文本样式?” 无法分配给参数类型“TextStyle”

我在使用我的 flutter 应用程序时遇到此 null 安全错误。

The argument type 'TextStyle?' can't be assigned to the parameter type 'TextStyle'.
Run Code Online (Sandbox Code Playgroud)

这是引发此错误的代码片段:

The argument type 'TextStyle?' can't be assigned to the parameter type 'TextStyle'.
Run Code Online (Sandbox Code Playgroud)

VS Code 建议此解决方案将 not 运算符放在参数末尾。

ButtonStyle(textStyle: MaterialStateProperty.all<TextStyle>(Theme.of(context).textTheme.button!))
Run Code Online (Sandbox Code Playgroud)

问题:这是一个很好的做法吗?在我的代码中,在这种情况下还有哪些其他可能的解决方案?

dart flutter

13
推荐指数
2
解决办法
2万
查看次数

标签 统计

dart ×1

flutter ×1