From b935c2a29d357fbc23a939ef8d8010d1e24e5184 Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 24 Feb 2021 19:34:42 +0000 Subject: [PATCH] fix fromJson for CustomerCountry --- LabelStoreMax/lib/models/customer_country.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/LabelStoreMax/lib/models/customer_country.dart b/LabelStoreMax/lib/models/customer_country.dart index a86be52..ea8d8a8 100644 --- a/LabelStoreMax/lib/models/customer_country.dart +++ b/LabelStoreMax/lib/models/customer_country.dart @@ -26,9 +26,18 @@ class CustomerCountry { } CustomerCountry.fromJson(Map json) { - countryCode = json['country_code']; - name = json['name']; - state = DefaultShippingState.fromJson(json['state']); + if (json == null) { + return; + } + if (json['country_code'] != null) { + countryCode = json['country_code']; + } + if (json['name'] != null) { + name = json['name']; + } + if (json['state'] != null) { + state = DefaultShippingState.fromJson(json['state']); + } } bool hasState() {