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.
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'.

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'.的更多相关文章
- 编译PHP 报错:node.c: In function dom_canonicalization
编译PHP 报错:node.c: In function dom_canonicalization /opt/php-5.2.17/ext/dom/node.c:1953: error: deref ...
- 关于IONIC 报错 XX is not a function
刚开始 做一个项目,总是报错"XX is not a function" 最后发现 原因 , 原来是 服务的 注入位置 有问题. angular.module(" ...
- JS function document.onclick(){}报错Syntax error on token "function", delete this token
JS function document.onclick(){}报错Syntax error on token "function", delete this token func ...
- 使用CI遇到的问题报错:Call to undefined function base_url()
问题来源:在HTML文件中使用base_url()函数引入CSS文件时,发现报错:Call to undefined function base_url() 研究了一下才知道是因为没有加载url小助手 ...
- jquery 报错 $.cookie is not a function()
jquery 报错 $.cookie is not a function() ——我是之前可以运行的项目,突然报这个错误,很奇怪. 这是jquery的cookie插件报错. 插件名: jquery.c ...
- JS function document.onclick(){}报错Syntax error on token "function", delete this token - CSDN博客
原文:JS function document.onclick(){}报错Syntax error on token "function", delete this token - ...
- 不知道哪里alert undefined 用下面的语句是js报错.F12能提示报错的地方window.alert=function(aa){ if (typeof (aa)"undefined"){ throw "就是这";}};
不知道哪里alert undefined 用下面的语句是js报错.F12能提示报错的地方 var oldalert=window.alert; window.alert=function(aa){ i ...
- Flutter报错记录
1.Could not find an option named "androidx". Run 'flutter -h' (or 'flutter -h') for avai ...
- flutter报错:NoSuchMethodError: The method '>' was called on null.
写了个list,发现出不来,报错 flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSem ...
- objc_msgSend()报错Too many arguments to function call ,expected 0,have3
Build Setting--> Apple LLVM 6.0 - Preprocessing--> Enable Strict Checking of objc_msgSend Call ...
随机推荐
- 14.api根路由
我们可以通过使用超链接来提高我们APi的内聚力和可发现性 一.为我们的API创建一个根路径 我们的视图有很多个url,但是没有一个入口点,可以使用@api_view创建一个根路径 #views.p ...
- 某 .NET RabbitMQ SDK 有采集行为,你怎么看?
一:背景 1.讲故事 前几天有位朋友在微信上找到我,说他的一个程序上了生产之后,被运维监控定位到这个程序会向一个网址为: http://m.365ey.net 上不定期打数据,而且还是加密的格式,要他 ...
- ahk精简自用
;9:03 2022/8/20 自用 #NoEnv #Warn #SingleInstance Force ;设工作目录为桌面 SetWorkingDir %A_Desktop% ;托盘提示必须放在热 ...
- 云实例初始化工具cloud-init源码分析
源码分析 代码结构 cloud-init的代码结构如下: cloud-init ├── bash_completion # bash自动补全文件 │ └── cloud-init ├── Chan ...
- Node.js的学习(三)node.js 开发web后台服务
一.Express -- Web开发框架 1.Express是什么? Express 是一个简洁而灵活.目前最流行的基于Node.js的Web开发框架, 提供了一系列强大特性帮助你创建各种 Web 应 ...
- maple软件安装教程
Maple2022适用于Win7/10/11(64位)系统,亲测可用! Maple2022 WIN10 64位安装步骤:1.先使用"百度网盘"下载MPE22_CN_x64安装包到电 ...
- Python图像处理丨5种图像处理特效
摘要:本篇文章主要讲解了图像常见的特效处理,从处理效果图.算法原理.代码实现三个步骤进行详细讲解,涉及图像素描特效.怀旧特效.光照特效.流年特效.图像滤镜等. 本文分享自华为云社区<[Pytho ...
- 篇(18)-Asp.Net Core入门实战-文章管理之文章内容管理(下拉框二级结构递归)
篇(18)-Asp.Net Core入门实战-文章管理之文章内容管理(下拉框二级结构递归实现) 文章管理是CMS系统的核心表之一,存储文章内容,特点就是字段端,属性多,比如是否标识为热点.推荐等属性, ...
- Gorm源码学习-数据库连接
1 前言 gorm源码地址: Gorm , 本文基于commit:cef3de694d9615c574e82dfa0b50fc7ea2816f3e 官方入门指南: Dosc 2 连接数据库代码示例 目 ...
- 是时候考虑升级 JDK 17 了
Spring,作为 Java EE 的事实规范,在2022年11月16日发布了最新的 6.0.0 GA 版本.这个版本是框架后续新生代的初始版本,拥抱持续创新的 OpenJDK 和 Java 生态.新 ...