type '(BuildContext, int) => dynamic' is not a subtype of type '(BuildContext, int) => Widget'

源码如下:

import 'package:flutter/material.dart';
import 'post.dart'; void main() {
runApp(MaterialApp(
title: 'Returning Data',
home: HomePage(),
));
} class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter SnackBar'),
),
body: Center(
child: new ListViewLayout(),
));
}
} class ListViewLayout extends StatelessWidget {
_istviewItemBuilder(BuildContext context, int index) {
return Text(posts[index].author);
} @override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: posts.length, itemBuilder: _istviewItemBuilder);
}
}

原因是因为_istviewItemBuilder没写 返回值类型Widget 加上就可以

import 'package:flutter/material.dart';
import 'post.dart'; void main() {
runApp(MaterialApp(
title: 'Returning Data',
home: HomePage(),
));
} class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter SnackBar'),
),
body: Center(
child: new ListViewLayout(),
));
}
} class ListViewLayout extends StatelessWidget {
Widget _istviewItemBuilder(BuildContext context, int index) {
return Text(posts[index].author);
} @override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: posts.length, itemBuilder: _istviewItemBuilder);
}
}

flultter listview异常type '(BuildContext, int) => dynamic' is not a subtype of type '(BuildContext, int) => Widget'的更多相关文章

  1. error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'

    char & operator[](int i);const char & operator[](int i);/*const char & operator(int i);* ...

  2. CAST function should support INT synonym for SIGNED. i.e. CAST(y AS INT)

      Login / Register Developer Zone Bugs Home Report a bug Statistics Advanced search Saved searches T ...

  3. Spring错误之org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'bookService' is expected to be of type 'pw.fengya.tx.BookService' but was actually of type 'com.sun.proxy.$Proxy1

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cas ...

  4. 出错:Failed to convert property value of type 'org.apache.ibatis.session.defaults.DefaultSqlSessionFactory' to required type 'java.lang.String' for property 'sqlSessionFactoryBeanName';

    出错的详细信息: 3 ERROR [http-nio-80-exec-3] org.springframework.web.servlet.DispatcherServlet - Context in ...

  5. Refused to execute script from '....js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.md

    目录 问题描述 解决过程 总结 问题描述 在整合 Spring Boot.Spring Security.Thymeleaf 的练习中,对页面进行调试时,发现如下错误提示: Refused to ex ...

  6. Attaching an entity of type 'xxx' failed because another entity of the same type already has the same primary key value.

    问题的详细描述: Attaching an entity of type 'xxxxx' failed because another entity of the same type already ...

  7. because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checkin

    1 前言 浏览器报错误(chrome和firefox都会):because its MIME type ('text/html') is not a supported stylesheet MIME ...

  8. Validation异常:No validator could be found for constraint '.....' validating type 'java.lang.Integer'.

    javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'java ...

  9. 异常: Bean named 'org.springframework.transaction.interceptor.TransactionInterceptor#0' is expected to be of type 'org.aopalliance.aop.Advice' but was actually of type 'org.springframework.transaction.i

    场景: 在使用spring整合hibernate事务时报错解决: spring-aop中已经包含aopaliance,删除多余的jar包

随机推荐

  1. vim 添加显示和行号

    方法一: 1.显示当前行行号,在VI的命令模式下输入 :nu 2.显示所有行号,在VI的命令模式下输入 :set nu :set nonu 关闭 方法二: 使用vi编辑~/.vimrc文件,在该文件中 ...

  2. 引用vector里的元素被删除后,引用会怎么样?

    引用的定义不多说,直接看做变量的别名就可以了.有一天写着写着代码,突然想到,如果对vector里某个元素设置引用后,将这个元素从vector里删除会怎么样?我思考了下,认为那个元素会被删除,但是引用还 ...

  3. Codeforces 898 贪心关闭最少闹钟 优先队列最少操作构造N/2squares 讨论情况哈希数字串分割a+b=c

    A /* Huyyt */ #include <bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mkp(a,b) ...

  4. 02/Oct/2019:11:55:28 类型的时间转换为

    public static String upDataTime(String time) { Date upTime = new Date(); String newtime = null; Simp ...

  5. CPU、CPU核与线程的关系

    CPU相关概念: CPU:独立的中央处理单元,体现在主板上是有多个CPU的插槽. CPU cores:在每一个CPU上,都可能有多个核(core),每一个核中都有独立的一套ALU.FPU.Cache等 ...

  6. 微信小程序-自制弹出框禁止页面上下滑动

    弹出 fixed 弹窗后,在弹窗上滑动会导致下层的页面一起跟着滚动. 解决方法: 在弹出层加上 catchtouchmove 事件 两种方法:(在电脑上测试是没有用的,这是触摸事件.因此,需要在手机端 ...

  7. Python 分页和shell命令行模式

    前言 除了手动添加你的文章后外,你还可以用命令行来添加,python 自带了一种命令行 就是 shell 快速添加博文:Shell命令行模式 在你的目录下:mysite python manage.p ...

  8. pyqt5-信号与槽

    个人理解:pyqt5的信号就是C++中事件,比如鼠标单击事件;pyqt5中的槽就是c++事件函数,比如单击之后要去执行的函数 例子一 一个信号连接一个槽 import sysfrom PyQt5.Qt ...

  9. 8.django单独执行文件

    import os import django # 导入django os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'noju.settings')d ...

  10. 使用swagger生成API说明文档

    使用swagger生成API说明文档本文由个人总结,如需转载使用请标明原著及原文地址没有导出!!!!!不要整天给我留言导出呢,那个是你们百度的时候下面的推荐文章带的关键字,要做导出从swagger取数 ...