Darta is annotation based Dart data classes generator.
Just annotate your abstract class with @Data
annotation:
import 'package:darta/darta.dart';
part 'example.g.dart';
@Data()
abstract class Dog {
String get name;
String get breed;
}
Then run build_runner
. That's all! You got few generated classes:
- Child class implementing
toString()
,hashCode
and==
. - Factory class with
create()
method for usual instantiating andfromMap()
for instantiating from the map. copyWith()
andtoMap()
extensions.
What you DON'T get:
- Red code until
build_runner
run. - Polluted code base.