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. 给oracle命令的参数赋值

    ''' <summary>    '''   给oracle命令的参数赋值    ''' </summary>    ''' <param name="cmd& ...

  2. jquery 保留两位小数

    jquery 通过 toFixed 保留两位小数 <script> var num = 12.21654; console.log(num.toFixed(2)) </script& ...

  3. u-boot initf_bootstage函数分析

    这篇博客主要分析 init_sequence_f 函数指针数组中的initf_bootstage函数: static int initf_bootstage(void){    bool from_s ...

  4. rsync+inotify实时数据同步单目录实战

    rsync+inotify实时数据同步单目录实战   rsync+inotify实时数据同步单目录实战 inotify是一个强大的.细粒度的.异步的文件系统事件监控机制,linux内核从2.6.13起 ...

  5. linux 上搭建sftp服务

    原文链接:https://www.cnblogs.com/yanduanduan/p/9046723.html sftp和ftp的区别 FTP是一种文件传输协议,一般是为了方便数据共享的.包括一个FT ...

  6. IDC机房跳线

    服务网卡口与配线架 这里有一根网线 记录方式 签 A:23FM-23U-T07 (配线架网线) B:23FM-23U-NIC1(服务器网线) 在配线架的机柜旁边一定写明了 跳线的对面的   交换和配线 ...

  7. html acronym标签 语法

    html acronym标签 语法 作用:定义首字母缩略词. 说明:如果首字母缩略词是一个单词,则可以被读出来,例如 NATO, NASA, ASAP, GUI.通过对只取首字母缩略词进行标记,您就能 ...

  8. C++ - 操作运算符

    一.操作运算符 操作运算符:在C++中,编译器有能力将数据.对象和操作符共同组成表达式,解释为对全局或成员函数的调用 该全局或成员函数被称为操作符函数,程序员可以通过重定义函数操作符函数,来达到自己想 ...

  9. 浅谈BSGS(大步小步)及其扩展

    用途: 一般用来求\(a^x\equiv b\,\,(mod\,p)\)的最小正整数解,其中gcd(a,p)=1 设\(u=\lceil sqrt(p)\rceil\),则式子可以转化为\(a^{iu ...

  10. 损坏的RAID5

    损坏的RAID5 string讀入卡cin 関同步 ios::sync_with_stdio(false) 由塊號映射到具體位置 塊號id對應第col個字符串 字符串開始的位置st #include& ...