flutter - 尝试运行颤振应用程序时出现错误。参数的值不能为“null”
问题描述
这是我得到的错误,请告诉我该怎么做?
lib/models.dart:21:21: 错误:参数 'description' 的值不能为 'null',因为它的类型为
'String',但隐含的默认值为 'null'。尝试添加显式的非“null”默认值或“required”修饰符。WeatherInfo({this.description, this.icon});
lib/models.dart:21:39:错误:参数 'icon' 的值不能为 'null',因为它的类型为 'String',
但隐含的默认值是 'null'。尝试添加显式的非“null”默认值或“required”修饰符。WeatherInfo({this.description, this.icon});
lib/models.dart:33:25: 错误:参数“温度”的值不能为“空”,因为它的类型为
“双”,但隐含的默认值为“空”。尝试添加显式的非“null”默认值或“required”修饰符。温度信息({this.temperature});
lib/models.dart:50:25: 错误:参数“cityName”的值不能为“null”,因为它的类型为
“String”,但隐含的默认值为“null”。尝试添加显式的非“null”默认值或“required”修饰符。WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});
lib/models.dart:50:40: 错误:参数“tempInfo”的值不能为“null”,因为它的类型为
“TemperatureInfo”,但隐含的默认值为“null”。“TemperatureInfo”来自“package:flutterapp/models.dart”(“lib/models.dart”)。尝试添加显式的非“null”默认值或“required”修饰符。WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});
lib/models.dart:50:55: 错误:参数“weatherInfo”的值不能为“null”,因为它的类型为
“WeatherInfo”,但隐含的默认值为“null”。'WeatherInfo' 来自'package:flutterapp/models.dart' ('lib/models.dart')。尝试添加显式的非“null”默认值或“required”修饰符。WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});
lib/main.dart:19:19:错误:应该初始化字段“_response”,因为它的类型“WeatherResponse”不允许为空。'WeatherResponse' 来自'package:flutterapp/models.dart' ('lib/models.dart')。WeatherResponse_response;
解决方案
This is the line with error.
WeatherResponse _response;
必须初始化不可为空的实例字段“_response”。
推荐阅读
- javascript - Sanity CMS,在文档中引用数组
- git - 如何跨功能分支保持正确的合并顺序?
- java - Java代码只输出main方法,跳过静态方法
- javascript - 如何下载 url 中没有扩展名的文件?或绕过下载提示?
- perl - 我应该如何处理 Activestate 从他们的 Perl 中删除 PPM?
- python - 为什么 sorted 不能正确排序数组?
- node.js - 如何使用 Express 在 NodeJS 的 errorHandler 中间件中返回 JSON 响应?
- html - 在响应式网站的最底部创建粘性导航栏时遇到问题
- c# - 使用 .Net 将 Pascal Case 字符串转换为 Dash Case
- polymorphism - 在 sml 中获取 ''a 类型而不是 'a