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包
随机推荐
- python脚本实现向钉钉群组发送消息
一.json格式 import json import requests def sendmessage(message): url = 'https://oapi.dingtalk.com/robo ...
- Centos7下lvs负载均衡lvs-tun模式配置
一.架构 director:172.28.18.69 vip:172.28.18.70 real server1:172.28.18.71 real server2:172.28.18.78 二.两台 ...
- 清北学堂提高组突破营游记day5
长者zhx来啦.. (又要送冰红茶了...) zhx一上来就讲动态规划...是不是要逼死人.... 动态规划: 最简单的例子:斐波那契数列.因为他是递推(通项公式不算)的,所以前面的已经确定的项不会影 ...
- 描述GPT是什么?
介绍: 全球唯一标识分区表(GUID Partition Table,缩写:GPT)是一个实体硬盘的分区表的结构布局的标准.它是可扩展固件接口(UEFI)标准(被Inter用于代替个人计算机的BIOS ...
- shiro框架学习-4- Shiro内置JdbcRealm
1. JdbcRealm 数据库准备 JdbcRealm就是用户的角色,权限都从数据库中读取,也就是用来进行用户认证授权的安全数据源更换为从数据库中读取,其他没有差别,首先在数据库创建三张表: CR ...
- nginx展示文件目录
1. 如何让nginx显示文件夹目录 vi /etc/nginx/conf.d/default.conf 添加如下内容: location / { root /data/www/file //指定实际 ...
- 苹果CMSv10对接微信公众号教程
首先声明下,对接公众号的话需要自行注册公众号“订阅号” 对接失败的原因大多是域名变红导致!简单的测试方法就是把域名链接发给qq好友或是qq群里看看有没有变红 域名变红以后大概率不会对接成功的,请知悉 ...
- 有色物体检测opencv+python
import cv2 import numpy as np import matplotlib.pyplot as plt cap=cv2.VideoCapture(0) while(1): ret, ...
- 大哥带的Orchel数据库时间盲注
0X01Oracle基于延时的盲注总结 0x00 前言 oracle注入中可以通过页面响应的状态,这里指的是响应时间,通过这种方式判断SQL是否被执行的方式,便是时间盲注: oracle的时间盲注通常 ...
- sqli-labs(26)
0X01 测试闭合 单引号报错 双引号不报错 ’闭合 构造语句 过滤了空格和and ?id=' anandd 1=1%23 ?id='+anandd+1=1%23 百度一下 一去看源码 真的顶不住 ...