Update toJson on base model
This commit is contained in:
parent
ad17b46cc9
commit
db4b9af0cd
@ -7,7 +7,9 @@ abstract class BaseModel<T> {
|
||||
|
||||
T fromMap(Map<String, dynamic> map);
|
||||
|
||||
T fromJson(String json);
|
||||
T fromJson(String json) {
|
||||
return fromMap(decode(json));
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
|
@ -25,10 +25,5 @@ class Category extends BaseModel<Category> {
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Category fromJson(String json) {
|
||||
return fromMap(decode(json));
|
||||
}
|
||||
|
||||
static Category fromJsonString(dynamic json) => Category().fromJson(json);
|
||||
}
|
||||
|
@ -29,10 +29,5 @@ class Product extends BaseModel<Product> {
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
Product fromJson(String json) {
|
||||
return fromMap(decode(json));
|
||||
}
|
||||
|
||||
static Product fromJsonString(String json) => Product().fromJson(json);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user