serializer_interface 0.0.1 copy "serializer_interface: ^0.0.1" to clipboard
serializer_interface: ^0.0.1 copied to clipboard

A package, that provides interfaces for serializable objects and serializers of those objects.

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);
1
likes
110
pub points
2%
popularity

Publisher

unverified uploader

A package, that provides interfaces for serializable objects and serializers of those objects.

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on serializer_interface