"copy_annotation" is a annotation based code generation package for Flutter that generates a copyWith method with extension functions for immutable classes. Work together with copy_annotation_gen to generate code.
Usage
dependencies:
copy_annotation: ^latest_version
Then, you need to add the following dependencies for code generation:
dev_dependencies:
build_runner: ^latest_version
copy_annotation_gen: ^latest_version
Example
@copy
class Employee {
final int id;
final String name;
Employee({required this.id,required this.name})
}
final emp1 = Employee(id:1,name:"John");
final emp2 = emp1.copy(id:2,name:"Mina");