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'.的更多相关文章

  1. 编译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 ...

  2. 关于IONIC 报错 XX is not a function

    刚开始 做一个项目,总是报错"XX is not  a function"   最后发现 原因 ,   原来是 服务的 注入位置 有问题. angular.module(" ...

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

  4. 使用CI遇到的问题报错:Call to undefined function base_url()

    问题来源:在HTML文件中使用base_url()函数引入CSS文件时,发现报错:Call to undefined function base_url() 研究了一下才知道是因为没有加载url小助手 ...

  5. jquery 报错 $.cookie is not a function()

    jquery 报错 $.cookie is not a function() ——我是之前可以运行的项目,突然报这个错误,很奇怪. 这是jquery的cookie插件报错. 插件名: jquery.c ...

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

  7. 不知道哪里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 ...

  8. Flutter报错记录

    1.Could not find an option named "androidx". Run 'flutter -h' (or 'flutter   -h') for avai ...

  9. flutter报错:NoSuchMethodError: The method '>' was called on null.

    写了个list,发现出不来,报错 flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSem ...

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

随机推荐

  1. 基于 Redis 生成分布式订单号

    环境依赖: //spingBoot <version>2.6.6</version> //jdk11 <dependency> <groupId>org ...

  2. Eclipse插件RCP桌面应用开发的点点滴滴

    Eclipse插件开发的点点滴滴 新公司做的是桌面应用程序, 与之前一直在做的web页面 ,相差甚大 . 这篇文章是写于2022年10月底,这时在新公司已经入职了快三月.写作目的是:国内对于eclip ...

  3. Spring中过滤器(Filter)和拦截器(Interceptor)的区别和联系

    在我们日常的开发中,我们经常会用到Filter和Interceptor.有时同一个功能.Filter可以做,Interceptor也可以做.有时就需要考虑使用哪一个比较好.这篇文章主要介绍一下,二者的 ...

  4. 分清国内版FireFox和国际版FireFox

    FireFox现在成为越来越多人替代Chrome的选择.但与Chrome不同的是,FireFox无论桌面端还是移动端,都有着『国际』和『国内』版本的区分. 二.正确的下载地址 2.1国内版的混淆视听: ...

  5. Pthread 并发编程(一)——深入剖析线程基本元素和状态

    Pthread 并发编程(一)--深入剖析线程基本元素和状态 前言 在本篇文章当中讲主要给大家介绍 pthread 并发编程当中关于线程的基础概念,并且深入剖析进程的相关属性和设置,以及线程在内存当中 ...

  6. Istio Ambient Mesh七层服务治理图文详解

    摘要:本文主要集中剖析Ambient mesh七层服务治理相关内容. 本文分享自华为云社区<Istio Ambient Mesh七层服务治理图文详解>,作者:华为云云原生团队. 由于Amb ...

  7. 【笔记】CF1714F Build a Tree and That Is It 及相关

    题目传送门 细节较多的构造题. 解决思路 题目中虽然说是无根树,但我们可以钦定这棵树的根为 1,方便构造,这是不影响结果的. 以下记给定的三段长度为 \(a,b,c\) . 先考虑无解的情况. 首先, ...

  8. SQLSever数据库基本操作

    一.SQLSever数据库基本操作 1.创建数据库 use master if exists(select * from sysdatabases where name='SMDB') drop da ...

  9. 定制ASP.NET Core的身份认证

    大家好,我是张飞洪,感谢您的阅读,我会不定期和你分享学习心得,希望我的文章能成为你成长路上的垫脚石,让我们一起精进. 在本章,我们将学习如何定制ASP.NET Core认证机制.微软把安全认证当做AS ...

  10. 微信小程序的学习(二)

    一.数据绑定 1.数据绑定的基本原则 在 data 中定义数据 在 wxml 中使用数据 2.如何在 data 里面定义数据? 在页面对应的 .js 文件中,把数据定义到 data 对象中即可: 3. ...