[英]I am getting errors when trying to run flutter app. The parameter can't have a value of 'null'
This is the errors that I get please tell me what to do?这是我得到的错误,请告诉我该怎么做?
lib/models.dart:21:21: Error: The parameter 'description' can't have a value of 'null' because of its type lib/models.dart:21:21: 错误:参数“描述”的值不能为“空”,因为它的类型
'String', but the implicit default value is 'null'. 'String',但隐式默认值为 'null'。 Try adding either an explicit non-'null' default value or the 'required' modifier.尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherInfo({this.description, this.icon}); WeatherInfo({this.description, this.icon});
lib/models.dart:21:39: Error: The parameter 'icon' can't have a value of 'null' because of its type 'String', lib/models.dart:21:39: 错误:参数“icon”的值不能为“null”,因为它的类型是“String”,
but the implicit default value is 'null'.但隐含的默认值为“null”。 Try adding either an explicit non-'null' default value or the 'required' modifier.尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherInfo({this.description, this.icon}); WeatherInfo({this.description, this.icon});
lib/models.dart:33:25: Error: The parameter 'temperature' can't have a value of 'null' because of its type lib/models.dart:33:25: 错误:参数“温度”的值不能为“空”,因为它的类型
'double', but the implicit default value is 'null'. 'double',但隐式默认值为 'null'。 Try adding either an explicit non-'null' default value or the 'required' modifier.尝试添加明确的非“空”默认值或“必需”修饰符。 TemperatureInfo({this.temperature});温度信息({this.temperature});
lib/models.dart:50:25: Error: The parameter 'cityName' can't have a value of 'null' because of its type lib/models.dart:50:25: 错误:参数“cityName”的值不能为“null”,因为它的类型
'String', but the implicit default value is 'null'. 'String',但隐式默认值为 'null'。 Try adding either an explicit non-'null' default value or the 'required' modifier.尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo}); WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});
lib/models.dart:50:40: Error: The parameter 'tempInfo' can't have a value of 'null' because of its type lib/models.dart:50:40: 错误:参数“tempInfo”的值不能为“null”,因为它的类型
'TemperatureInfo', but the implicit default value is 'null'. 'TemperatureInfo',但隐式默认值为 'null'。 'TemperatureInfo' is from 'package:flutterapp/models.dart' ('lib/models.dart'). 'TemperatureInfo' 来自 'package:flutterapp/models.dart' ('lib/models.dart')。 Try adding either an explicit non-'null' default value or the 'required' modifier.尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo}); WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});
lib/models.dart:50:55: Error: The parameter 'weatherInfo' can't have a value of 'null' because of its type lib/models.dart:50:55: 错误:参数“weatherInfo”的值不能为“null”,因为它的类型
'WeatherInfo', but the implicit default value is 'null'. 'WeatherInfo',但隐式默认值为 'null'。 'WeatherInfo' is from 'package:flutterapp/models.dart' ('lib/models.dart'). 'WeatherInfo' 来自 'package:flutterapp/models.dart' ('lib/models.dart')。 Try adding either an explicit non-'null' default value or the 'required' modifier.尝试添加明确的非“空”默认值或“必需”修饰符。 WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo}); WeatherResponse({this.cityName, this.tempInfo, this.weatherInfo});
lib/main.dart:19:19: Error: Field '_response' should be initialized because its type 'WeatherResponse' doesn't allow null. lib/main.dart:19:19: 错误:字段 '_response' 应该被初始化,因为它的类型 'WeatherResponse' 不允许为 null。 'WeatherResponse' is from 'package:flutterapp/models.dart' ('lib/models.dart'). “天气响应”来自“package:flutterapp/models.dart”(“lib/models.dart”)。 WeatherResponse _response; WeatherResponse _response;
I can't help you if you don't send the code, you have to send it instead of the entire debug log.如果您不发送代码,我无法帮助您,您必须发送它而不是整个调试日志。
Press Ctrl + k to enter code in your ask按 Ctrl + k 在您的询问中输入代码
This is the line with error.
WeatherResponse _response;
不可为空的实例字段 '_response' 必须被初始化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.