» не является подтипом ошибки типа «int»

#flutter

Вопрос:

Я пытаюсь закодировать приложение погоды., я хочу, чтобы в нижней части экрана были маленькие карточки, которые отображали бы данные о погоде пользователя на ближайшие 5 дней, но я получаю эту ошибку

 var temps = new List.filled(5, 0);
var abbrs = new List.filled(5, 0);

setState(() {
      weather = locationTempParsed['consolidated_weather'][0]['the_temp'].round();

      for (int i = 0; i < temps.length; i  ) {
        temps[i] = locationTempParsed['consolidated_weather'][i   1]['the_temp'].round();
        abbrs = abbrs[i] = locationTempParsed['consolidated_weather'][i   1];

        //  ['weather_state_abbr'];
      }

DailyWeather(
    date: 'Tuesday',
    temp: temps[1].toString(),
    image: abbrs[1].toString()),
 

Ответ №1:

Это выглядит так, как будто вы где-то назначаете строку вместо int.

 var temps = new List.filled(5, 0);
var abbrs = new List.filled(5, 0);

setState(() {
      weather = locationTempParsed['consolidated_weather'][0]['the_temp'].round();

      for (int i = 0; i < temps.length; i  ) {
        temps[i] = locationTempParsed['consolidated_weather'][i   1]['the_temp'].round();
         // Check Here
        abbrs[i] = locationTempParsed['consolidated_weather'][i   1];
      }

DailyWeather(
    date: 'Tuesday',
    temp: temps[1], // Check Here
    image: abbrs[1].toString()),