繁体   English   中英

尝试运行 flutter 应用程序时出现错误。 参数的值不能为“null”

[英]I am getting errors when trying to run flutter app. The parameter can't have a value of 'null'

这是我得到的错误,请告诉我该怎么做?

lib/models.dart:21:21: 错误:参数“描述”的值不能为“空”,因为它的类型
'String',但隐式默认值为 'null'。 尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherInfo({this.description, this.icon});

lib/models.dart:21:39: 错误:参数“icon”的值不能为“null”,因为它的类型是“String”,
但隐含的默认值为“null”。 尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherInfo({this.description, this.icon});

lib/models.dart:33:25: 错误:参数“温度”的值不能为“空”,因为它的类型
'double',但隐式默认值为 'null'。 尝试添加明确的非“空”默认值或“必需”修饰符。 温度信息({this.temperature});

lib/models.dart:50:25: 错误:参数“cityName”的值不能为“null”,因为它的类型
'String',但隐式默认值为 'null'。 尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});

lib/models.dart:50:40: 错误:参数“tempInfo”的值不能为“null”,因为它的类型
'TemperatureInfo',但隐式默认值为 'null'。 'TemperatureInfo' 来自 'package:flutterapp/models.dart' ('lib/models.dart')。 尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});

lib/models.dart:50:55: 错误:参数“weatherInfo”的值不能为“null”,因为它的类型
'WeatherInfo',但隐式默认值为 'null'。 'WeatherInfo' 来自 'package:flutterapp/models.dart' ('lib/models.dart')。 尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});

lib/main.dart:19:19: 错误:字段 '_response' 应该被初始化,因为它的类型 'WeatherResponse' 不允许为 null。 “天气响应”来自“package:flutterapp/models.dart”(“lib/models.dart”)。 WeatherResponse _response;

如果您不发送代码,我无法帮助您,您必须发送它而不是整个调试日志。

按 Ctrl + k 在您的询问中输入代码

This is the line with error.

  WeatherResponse _response;

不可为空的实例字段 '_response' 必须被初始化。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM