flultter listview异常type '(BuildContext, int) => dynamic' is not a subtype of type '(BuildContext, int) => Widget'
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'的更多相关文章
- 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);* ...
- 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 ...
- 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 ...
- 出错: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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 异常: 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包
随机推荐
- VMware虚拟机中的CentOS7安装Nginx后本机无法访问的解决办法
VMware虚拟机中的CentOS7安装Nginx后本机无法访问的解决办法 在linux上安装nginx 请参考:Linux Centos7 安装 nginx 在虚拟机centos7上安装nginx之 ...
- 【leetcode&CN&竞赛】1198.Find Smallest Common Element in All Rows
题目如下: 给你一个矩阵 mat,其中每一行的元素都已经按 递增 顺序排好了.请你帮忙找出在所有这些行中 最小的公共元素. 如果矩阵中没有这样的公共元素,就请返回 -1. 示例: 输入:mat = [ ...
- python中的文件读取
---恢复内容开始--- r模式,只读模式,不可写入,文件不存在会报错 #r模式,能读不能写,文件不存在会报错 f = open('a1.txt')#不写'r',默认只读 result = f.rea ...
- Linux 环境下 jar 加解密命令?
1.源码打jar包 jar -cvf demo-source.jar -C src/ . > log.txt 2.编译字节打jar包 jar -cvf demo-class.jar -C bin ...
- Codeforces 912D Fishs ( 贪心 && 概率期望 && 优先队列 )
题意 : 给出一个 N * M 的网格,然后给你 K 条鱼给你放置,现有规格为 r * r 的渔网,问你如果渔网随意放置去捕捞小鱼的情况下,捕到的最大期望值是多少? 分析 : 有一个很直观的想法就是 ...
- 文件操作:rewind()
函数名: rewind() 功 能: 将文件内部的位置指针重新指向一个流(数据流/文件)的开头 注意:不是文件指针而是文件内部的位置指针,随着对文件的读写文件的位置指针(指向当前读写字节)向后移动 ...
- 2018百度之星初赛A轮 度度熊拼三角
#include<bits/stdc++.h> using namespace std; int n; int a[1005]; int main() { int ans; ...
- HY中考游记
回首三年荏苒,还是有许多忘不了,有始有终,最后以一篇游记来记录落幕吧 Day -inf 为了准备中考从机(颓)房回到学校了,停课这么久,也该好好备考了 希望能回到以前的文化课水平QAQ Day -? ...
- 【Leetcode】最大的数
字符串比较大小 https://blog.csdn.net/jason_cuijiahui/article/details/79038468 http://www.cplusplus.com/refe ...
- wordcloud:让你的词语像云朵一样美
介绍 对文本中出现频率较高的关键词给予视觉化的显示 使用 python import jieba import codecs import wordcloud file = r"C:\U ...