Необработанное исключение при десериализации пустого поля с помощью json_serializable

Я получаю эту ошибку при попытке десериализации json, она выдает ошибку при разборе пустого поля. [ { "entity": "1", "name_alias": "NAME", "address": "ADDRESS", "zip": null, "town": "TOWN", }]

Вот часть кода, генерирующая исключение:

      CustomerListResp _$CustomerListRespFromJson(Map<String, dynamic> json) {
   return CustomerListResp()
    ..customers = (json['customers'] as List<dynamic>)
        .map((e) => Customer.fromJson((e as Map<String, dynamic>).map(
              (k, e) => MapEntry(k, e as Object), // throw exception when parsing the zip field
            )))
        .toList();
}
      json_serializable: ^4.0.2
flutter doctor -v
[√] Flutter (Channel stable, 2.0.4, on Microsoft Windows [version 10.0.17763.1879], locale fr-FR)
    • Flutter version 2.0.4 at C:\flutter
    • Framework revision b1395592de (3 weeks ago), 2021-04-01 14:25:01 -0700
    • Engine revision 2dce47073a
    • Dart version 2.12.2

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at AppData\Local\Android\Sdk
    • Platform android-29, build-tools 29.0.3
    • ANDROID_HOME = AppData\Local\Android\Sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code (version 1.55.2)
    • VS Code at \AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.21.0```

0 ответов

Другие вопросы по тегам