Skip to content

Commit b935c2a

Browse files
committed
fix fromJson for CustomerCountry
1 parent acffaad commit b935c2a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

LabelStoreMax/lib/models/customer_country.dart

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ class CustomerCountry {
2626
}
2727

2828
CustomerCountry.fromJson(Map<String, dynamic> json) {
29-
countryCode = json['country_code'];
30-
name = json['name'];
31-
state = DefaultShippingState.fromJson(json['state']);
29+
if (json == null) {
30+
return;
31+
}
32+
if (json['country_code'] != null) {
33+
countryCode = json['country_code'];
34+
}
35+
if (json['name'] != null) {
36+
name = json['name'];
37+
}
38+
if (json['state'] != null) {
39+
state = DefaultShippingState.fromJson(json['state']);
40+
}
3241
}
3342

3443
bool hasState() {

0 commit comments

Comments
 (0)