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 ...
随机推荐
- C语言整人关机程序
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char input ...
- @confirguration(proxyBeanMethods = false)的作用,如何选择Full模式和Lite模式
@Configuration(proxyBeanMethods = false) //告诉SpringBoot这是一个配置类 == 配置文件 public class MyConfig { @Bean ...
- C# 窗体相关知识
一 窗体 固定窗体大小,并不能最大/最小化: FormBorderStyle属性设置为:FixedSingleMaximizeBox = falseMinimizeBox = false都是在For ...
- 对比entrypoint以及cmd
如何查看 现有 images 的 入口信息 docker image inspect image_id { "entrypoint": "xxx" " ...
- win 10 玩红警/黑边,不能全屏,闪退
win 10玩红警黑边问题 1.下载ddraw.dll,放在游戏目录 下载链接:ddraw.dll 如果提示 选择保留就行了 2.Win 键+S键,搜索注册表,打开这个 进去按这个路径 计算机\ ...
- 更改grub2背景图片
在/etc/grub/default这里面修改东西然后update-grub来间接修改/boot/grub/grub.cfg中的内容 1.将png图片放进/boot/grub/目录下 2.update ...
- Zabbix与乐维监控对比分析(二)——Agent管理、自动发现、权限管理
上期我们详细介绍了Zabbix与乐维监控的架构与性能对比分析,透过架构与性能对比分析,用户可以对乐维监控之所以能成为"Zabbix企业版"有一个初步的认知.本篇是Zabbix对比乐 ...
- 【每日一题】【快慢指针相遇】2022年1月25日-NC3 链表中环的入口结点
描述给一个长度为n链表,若其中包含环,请找出该链表的环的入口结点,否则,返回null. 答案: /* public class ListNode { int val; ListNode next = ...
- 获取Exceptionless的日志
简言: 最近做项目要用到Exceptionless这个分布式日志组件,由于领导说日志需要提供给客户看,废话不多讲,咱直入主题了: 第一步:查看API文档 打开:http://127.0.0.1:500 ...
- 解决.net Core中WebApi自动Model验证导致数据格式不能统一
简言: 最近做项目用WebAPI Core时,想把返回数据的格式,统一弄成:{"errorMsg":"xxx","Data":"x ...