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. 1.pytest入门

    一.pytest单元测试框架 概念:单元测试是指在软件开发中,针对软件的最小单位(函数.方法等)进行正确性的检查测试          单元测试框架是自动化测试框架中的组成部分之一           ...

  2. HTML5+CSS3常见布局方式

    1.等高布局 1.1 代码 等高布局是指子元素在父元素中高度相等的布局方式 <div class="father"> <div class="f1&qu ...

  3. Asp.Net Core6.0中MediatR的应用CQRS

    1.前言 对于简单的系统而言模型与数据可以进行直接的映射,比如说三层模型就足够支撑项目的需求了.对于这种简单的系统我们过度设计说白了无异于增加成本,因为对于一般的CRUD来说我们不用特别区分查询和增删 ...

  4. CAN总线数据链路层(一)

    1.通信机制 发送报文. 1.首先检测Bus状态,空闲 则发送 报文且回读         2.线与机制,若有两个节点同时发报文          报文结构:          通过ID进行仲裁(规则 ...

  5. mindxdl--common--http_handler.go

    // Copyright (c) 2021. Huawei Technologies Co., Ltd. All rights reserved.// Package common this file ...

  6. 基于python的数学建模---二维插值的三维图

    import numpy as np from mpl_toolkits.mplot3d import Axes3D import matplotlib as mpl from scipy impor ...

  7. 机器学习模型评价指标之ROC 曲线、 ROC 的 AUC 和 投资回报率

    前文回顾: 机器学习模型评价指标之混淆矩阵 机器学习模型评价指标之Accuracy.Precision.Recall.F-Score.P-R Curve.AUC.AP 和 mAP 1. 基本指标 1. ...

  8. rpm环境安装dpkg包管理工具

    rpm环境安装dpkg包管理工具 索引:dpkg-scanpackages.dpkg.dpkg-query.dpkg-source.dpkg-scansource 在centos.redhat.麒麟服 ...

  9. c++学习笔记(入门)

    1 struct和class的区别 struct成员变量(成员函数)的访问属性缺省的情况下默认为public. class成员变量(成员函数)的访问属性缺省的情况下默认为private. 2 初始化列 ...

  10. FCOS论文复现:通用物体检测算法

    摘要:本案例代码是FCOS论文复现的体验案例,此模型为FCOS论文中所提出算法在ModelArts + PyTorch框架下的实现.本代码支持FCOS + ResNet-101在MS-COCO数据集上 ...