Data classes are usually converted to a more generic form (string or map) when interacting with external libraries. I'm not sure of the scope of this library, but a feature to serialise the data classes would be great. It does not have to be a complete solution to compete with other emerging libraries, but complete enough to coexist with existing data_class
constructors and toString
methods.
A feature to serialise the attributes of a data class.
import 'package:data_class/data_class.dart';
@Data()
class Person {
final String name;
}
void main() {
// 🪨 Create a const instance with required, name parameters.
const dash = Person(name: 'Dash');
// Serialise
print(dash.toMap()); // {name: Dash} OR
print(dash.toJson(); // {"name": "Dash"}
// Deserialise
final sam = Person.fromMap({'name': 'Sam'}); // OR
final john = Person.fromJson('{"name": "John"}');
}