serializer_interface

Creator: coderz1093

Last updated:

0 purchases

serializer_interface Images
Add to Cart

Description:

serializer interface

A JsonSerializer interface for any model that is serializable (to Map<String, dynamic> and back).

Usage #
class MyModel{
final String myProperty;

MyModel({required this.myProperty});
}

class MySerializer implements JsonSerializer<MyModel>{
Map<String, dynamic> toJson(MyModel data) => {
"myProperty": data.myProperty
};

MyModel fromJson(Map<String, dynamic> json)
=> MyModel(myProperty: json["myProperty"] ?? "");
}

// use the serializer
final Map<String, dynamic> json = fetchFromDb();
final MyModel = MySerializer().fromJson(json);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.

Related Products

More From This Creator