mutable_copy_generator 0.2.4 mutable_copy_generator: ^0.2.4 copied to clipboard
Mutable copy generator.
mutable_copy_generator #
MutableCopy simplify copy of immutable object. Unlike CopyWith allow to set null value
Code generation #
Code generator for mutable_copy
import 'package:mutable_copy/mutable_copy.dart';
part 'employee.g.dart';
@imutable
@MutableCopy
class Employee {
final String fullName;
final String department;
final String team;
Employee({
this.fullName,
this.department,
this.team,
});
}
Add dependencies #
dependencies:
...
mutable_copy: ^0.2.4
dev_dependencies:
...
mutable_copy_generator: ^0.2.4
build_runner: ^1.9.0
Generate code #
flutter pub run build_runner build
Udage #
final e1 = Employee(
fullName: 'Max Hatson',
department: 'Mobile',
team: 'Flutter',
);
final eMutable = e1.copy((o) => o..fullName = 'Bob Watson');