简体   繁体   English

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

[英]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.

相关问题 Flutter 参数值不能为 null - Flutter The parameter can't have a value of null 我的 flutter 应用程序有问题。 由于某种原因,我无法运行我的任何 flutter 文件。 每次我尝试运行它都会给我一条错误消息 - I have a problem in my flutter app. For some reason I can't run any of my flutter files. Every time I try to run it keeps giving me an error message 我正在尝试从 Flutter for app 中的实时数据库 firebase 中获取数据。 所以,我尝试了几种方法,但无法使其工作 - I am trying to fetch data from real-time database firebase in flutter for app. So, I have tried couple ways but couldn't make it work 当我尝试运行我的 flutter 应用程序时,运行 gradle 时出现错误 - When i am trying to run my flutter app it getting an Error running gradle 我正在尝试在 flutter 中制作一个测验应用程序,以极客教程作为参考。我有以下错误 - I am trying to make a quiz app in flutter with geeks for geeks tutorial as reference.. i have following errors 我正在尝试在 flutter 应用程序中实现底部导航栏,但我的源代码中不断出现错误 - I am trying to implement a bottom navigation bar in a flutter app but I keep getting errors in my source code Flutter ,dart,参数 'colour' 因为它的类型不能有 'null' 的值,但是隐含的默认值是 'null' - Flutter ,dart,The parameter 'colour' can't have a value of 'null' because of its type, but the implicit default value is 'null' 参数“firebaseFirestore”因其类型而不能具有“null”值,但 flutter 中的隐式默认值为“null” - The parameter 'firebaseFirestore' can't have a value of 'null' because of its type, but the implicit default value is 'null' in flutter 不使用“required”时,参数的值不能为 null - The parameter can't have a value of null when 'required' is not used 我在 Flutter 中收到空参数错误,我该如何解决? - I am getting null parameter error in Flutter, how can I solve it?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM