From db4b9af0cdffc4aed9f85855b3829b75f6bced85 Mon Sep 17 00:00:00 2001 From: Sambo Chea Date: Fri, 28 Oct 2022 10:21:39 +0700 Subject: [PATCH] Update toJson on base model --- lib/sdk/models/base.dart | 4 +++- lib/sdk/models/category.dart | 5 ----- lib/sdk/models/product.dart | 5 ----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/sdk/models/base.dart b/lib/sdk/models/base.dart index d9ae70f..e965b88 100644 --- a/lib/sdk/models/base.dart +++ b/lib/sdk/models/base.dart @@ -7,7 +7,9 @@ abstract class BaseModel { T fromMap(Map map); - T fromJson(String json); + T fromJson(String json) { + return fromMap(decode(json)); + } @override String toString() { diff --git a/lib/sdk/models/category.dart b/lib/sdk/models/category.dart index e70399a..99bd5cd 100644 --- a/lib/sdk/models/category.dart +++ b/lib/sdk/models/category.dart @@ -25,10 +25,5 @@ class Category extends BaseModel { }; } - @override - Category fromJson(String json) { - return fromMap(decode(json)); - } - static Category fromJsonString(dynamic json) => Category().fromJson(json); } diff --git a/lib/sdk/models/product.dart b/lib/sdk/models/product.dart index b592e02..e98afb7 100644 --- a/lib/sdk/models/product.dart +++ b/lib/sdk/models/product.dart @@ -29,10 +29,5 @@ class Product extends BaseModel { }; } - @override - Product fromJson(String json) { - return fromMap(decode(json)); - } - static Product fromJsonString(String json) => Product().fromJson(json); }