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 ...
随机推荐
- UVA10763
菜鸡退役人来水黄了-- \(\sf{Solution}\) 搞不懂为什么要排序,这不是两个数组直接模拟的数数题吗. 读入后,对于每个学生,令他要去的学校以及他现在所在学校人数对应加一,再 check ...
- nrf9160 做modem—— 连接云(接入方式MQTT)
今天测试把nrf9160作为modem的例程Serial LTE Modem程序(后面简称slm),何为做modem,通俗来说就是将nrf9160作为无线模块,主控由其余MCU做,主控通过AT命令控制 ...
- Linux文件属性与管理
文件或目录属性主要包括: 索引节点,inode 文件类型 文件权限 硬链接个数 归属的用户和用户组 最新修改时间 查看命令 ls -lhi /opt 图解: Inode索引节点号,(人的身份证,家庭地 ...
- 现在入行Java真的还有出路吗?
现在入行Java还来的及吗?未来该如何抉择? 最近有点迷茫了,互联网好像一夜之间进入了寒冬一样,到处都是就业难的样子,当然,不可否认的是,那些努力的大佬依旧是斩获多个offer,但是,窝就一个小镇做题 ...
- mysql 子查询 联结 组合查询
子查询 SELECT cust_id FROM orders WHERE order_num IN (SELECT order_num FROM orderitems WHERE prod_id='T ...
- Flask(一)
pip install flask 依赖wsgi flask框架是基于werkzegu的wsgi实现,flask没有自己的wsgi 用户一旦请求,就会调用app.__call__方法 flask 路由 ...
- 用最少的代码模拟gRPC四种消息交换模式
我们知道,建立在HTTP2/3之上的gRPC具有四种基本的通信模式或者消息交换模式(MEP: Message Exchange Pattern),即Unary.Server Stream.Client ...
- ES系列二之常见问题解决
上篇ES系列一之java端API操作结束后本以为就相安无事了,但生产的问题是层出不穷的:下面我就再记录下近几周遇到的问题以及解决方案: 一 更新ES信息报错 报错信息如下: Use Elasticse ...
- 关于linux上strongswan客户端的配置
前言 这几天回家了,想连学校的vpn, 学校vpn用的是strongswan的EAP认证(不需要证书什么的),手机上直接用软件连接就可以了,windows也是内置了这个协议,无奈我用的是linux m ...
- 【每日一题】【回溯backtrace】N皇后
n 皇后问题 研究的是如何将 n 个皇后放置在 n×n 的棋盘上,并且使皇后彼此之间不能相互攻击. 给你一个整数 n ,返回所有不同的 n 皇后问题 的解决方案. 每一种解法包含一个不同的 n 皇后问 ...