简体   繁体   中英

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
'String', but the implicit default value is 'null'. Try adding either an explicit non-'null' default value or the 'required' modifier. 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',
but the implicit default value is 'null'. Try adding either an explicit non-'null' default value or the 'required' modifier. 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
'double', but the implicit default value is 'null'. Try adding either an explicit non-'null' default value or the 'required' modifier. TemperatureInfo({this.temperature});

lib/models.dart:50:25: Error: The parameter 'cityName' can't have a value of 'null' because of its type
'String', but the implicit default value is 'null'. Try adding either an explicit non-'null' default value or the 'required' modifier. 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
'TemperatureInfo', but the implicit default value is 'null'. 'TemperatureInfo' is from '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});

lib/models.dart:50:55: Error: The parameter 'weatherInfo' can't have a value of 'null' because of its type
'WeatherInfo', but the implicit default value is 'null'. 'WeatherInfo' is from '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});

lib/main.dart:19:19: Error: Field '_response' should be initialized because its type 'WeatherResponse' doesn't allow null. 'WeatherResponse' is from 'package:flutterapp/models.dart' ('lib/models.dart'). 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

This is the line with error.

  WeatherResponse _response;

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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