我在使用我的 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)
问题:这是一个很好的做法吗?在我的代码中,在这种情况下还有哪些其他可能的解决方案?