簡體   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