Bug Report
Summary
dart_mappable_plugin generates a concrete class definition that conflicts with the required abstract or sealed modifier introduced in freezed v3+. This causes build errors when using both packages together.
Following dependencies in my pubspec.yaml:
dependencies:
freezed_annotation: ^3.1.0
json_annotation: ^4.9.0
dev_dependencies:
build_runner: ^2.5.4
freezed: ^3.1.0
json_serializable: ^6.9.5
❌ Actual Behavior
The dart_mappable_plugin generates a concrete class Person, which clashes with the expected abstract base class for freezed v3+. This leads to build errors like:
Error: Missing concrete implementations of 'getter mixin _$Person on Object.firstName',
'getter mixin _$Person on Object.lastName',
'getter mixin _$Person on Object.age',
and 'mixin _$Person on Object.toJson'.
✅ Expected Behavior
The generated code should respect the freezed requirement for abstract classes and avoid conflicting with them.
💡 Solution
Simply add the abstract keyword to the class definition.
This resolves the conflict and satisfies both code generators:
@freezed
-class Person with _$Person {
+abstract class Person with _$Person {
const factory Person({
required String firstName,
required String lastName,
required int age,
}) = _Person;
factory Person.fromJson(Map<String, Object?> json) => _$PersonFromJson(json);
}
Reference
Bug Report
Summary
dart_mappable_plugingenerates a concrete class definition that conflicts with the requiredabstractorsealedmodifier introduced infreezedv3+. This causes build errors when using both packages together.Following dependencies in my
pubspec.yaml:❌ Actual Behavior
The
dart_mappable_plugingenerates a concreteclass Person, which clashes with the expectedabstractbase class forfreezedv3+. This leads to build errors like:✅ Expected Behavior
The generated code should respect the
freezedrequirement forabstractclasses and avoid conflicting with them.💡 Solution
Simply add the
abstractkeyword to the class definition.This resolves the conflict and satisfies both code generators:
Reference