程序笔记   发布时间:2022-07-11  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了flutter报错The type of the function literal can't be inferred because the literal has a block as its body.A value of type 'String?' can't be assigned to a variable of type 'String'.大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

flutter有一些报错如下

flutter报错The type of the function literal can't be inferred because the literal has a block as its body.A value of type 'String?' can't be assigned to a variable of type 'String'.

The type of the function literal can't be inferred because the literal has a block as its body. Try adding an explicit type to the variable.dart(top_level_function_literal_block) A value of type 'String?' can't be assigned to a variable of type 'String'. Try changing the type of the variable, or casTing the right-hand type to 'String'.

flutter报错The type of the function literal can't be inferred because the literal has a block as its body.A value of type 'String?' can't be assigned to a variable of type 'String'.

The type of the function literal can't be inferred because the literal has a block as its body. Try adding an explicit type to the variable.dart(top_level_function_literal_block) A value of type 'StatefulWidget Function(dynamiC)?' can't be assigned to a variable of type 'Function'. Try changing the type of the variable, or casTing the right-hand type to 'Function'.

The type of the function literal can't be inferred because the literal has a block as its body. Try adding an explicit type to the variable.

解决方案

// final String name = setTings.name;
final String? name = setTings.name;
// final Function pageContentBuilder = routes[name];
final Function pageContentBuilder = routes[name] as Function;

大佬总结

以上是大佬教程为你收集整理的flutter报错The type of the function literal can't be inferred because the literal has a block as its body.A value of type 'String?' can't be assigned to a variable of type 'String'.全部内容,希望文章能够帮你解决flutter报错The type of the function literal can't be inferred because the literal has a block as its body.A value of type 'String?' can't be assigned to a variable of type 'String'.所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。