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. 【JavaWeb】学习笔记——Ajax、Axios

    Ajax Ajax 介绍 AJAX(Asynchronous JavaScript And XML):异步的JavaScript 和 XML AJAX 的作用: 与服务器进行数据交换:通过AJAX可以 ...

  2. 二十二、Pod存储之volume

    Pod 的存储之volume ​容器磁盘上的文件的生命周期是短暂的,这就使得在容器中运行重要应用时会出现一些问题.首先,当容器崩溃时,kubelet 会重启它,但是容器中的文件将丢失--容器以干净的状 ...

  3. Spring Boot 项目自定义 banner

    前言 我们在启动 Spring Boot 项目时,控制台会打印出 Spring Boot 专属的标语,也称 banner(横幅标语/广告),效果如下: 实际上,上面这个 banner,我们可以自定义, ...

  4. 我服了!SpringBoot升级后这服务我一个星期都没跑起来!(上)

    最近由于各方面的原因在准备升级 Spring Cloud 和 Spring Boot,经过一系列前置的调研和分析,决定把Spring Boot 相关版本从 2.1.6 升级到 2.7.5,Spring ...

  5. clickhouse在风控-风险洞察领域的探索与实践

    一.风险洞察平台介绍 以Clickhouse+Flink实时计算+智能算法为核心架构搭建的风险洞察平台, 建立了全面的.多层次的.立体的风险业务监控体系,已支撑欺诈风险.信用风险.企业风险.小微风险. ...

  6. Python用yield form 实现异步协程爬虫

    很古老的用法了,现在大多用的aiohttp库实现,这篇记录仅仅用做个人的协程底层实现的学习. 争取用看得懂的字来描述问题. 1.什么是yield 如果还没有怎么用过的话,直接把yield看做成一种特殊 ...

  7. 用 vue3 中的 reduce(累加器) 随机生成100个字母,放入数组中,统计每个字母出现的次数

    一.首先不用 reduce() 来实现  代码如下: <template lang=""> <div> <h1>统计每个字母出现的次数,不使用r ...

  8. 【OpenStack云平台】SecureCRT 连接 CentOS虚拟机

    1.安装SecureCRT SecureCRT是一款支持SSH等协议的终端仿真软件,可以在windows下登录Linux服务器,这样大大方便了开发工作.安装SecureCRT可以通过网上的各种教程安装 ...

  9. RNN的PyTorch实现

    官方实现 PyTorch已经实现了一个RNN类,就在torch.nn工具包中,通过torch.nn.RNN调用. 使用步骤: 实例化类: 将输入层向量和隐藏层向量初始状态值传给实例化后的对象,获得RN ...

  10. 7 STL-deque

    ​ 重新系统学习c++语言,并将学习过程中的知识在这里抄录.总结.沉淀.同时希望对刷到的朋友有所帮助,一起加油哦!  生命就像一朵花,要拼尽全力绽放!死磕自个儿,身心愉悦! 写在前面,本篇章主要介绍S ...