flutter - 参数“问题”的值不能为“空”,因为它的类型为“列表”
问题描述
我是使用 VS Code 和颤振版本颤振的新手 - 2.12.0 <3.0.0
我的问题是我正在使用 contructor 将一个列表、一个函数和一个 int 值从一个 dart 类传递到另一个类,但是它们都出错了。
参数“questions”的值不能为“null”,因为它的类型为“List<Map<String, Object>>”,但隐含的默认值为“null”。
参数“answerQuestion”的值不能为“null”,因为它的类型为“Function”,但隐含的默认值为“null”。
参数“index”的值不能为“null”,因为它的类型为“int”,但隐含的默认值为“null”。
这是我的代码 -
感谢帮助
解决方案
问题出在 Quiz 构造函数中
而不是这个
const Quiz(
{@required this.questions,
@required this.answerQuestion,
@required this.index});
像这样声明
const Quiz(
{required this.questions,
required this.answerQuestion,
required this.index});
推荐阅读
- python - 从列表python中过滤单词
- reactjs - 在 React Router 4 中渲染 UI
- node.js - 从 nodeJS 应用程序到 MS SQL 的随机连接错误
- jsonschema - 如何根据另一个属性的值设置模式对象的类型?
- python - Python如何将DST文件转换为PNG文件?
- java - 如何在没有文件 I/O 的情况下打印 SealedObject 加密数据?
- angular - 我可以将临时对象保存在 HTML 中吗?
- sql - Big Query '发生内部错误...' 在有效查询上创建视图
- html - 为什么我的弹性物品会出现在容器外?
- powershell - 如何只删除相同的文件和文件夹