easy_copy_with 3.2.0 copy "easy_copy_with: ^3.2.0" to clipboard
easy_copy_with: ^3.2.0 copied to clipboard

Package for automatic generation of copyWith methods in Dart classes using @CopyWith annotation.

example/example.dart

import 'package:easy_copy_with_example/role.dart';
import 'package:easy_copy_with_example/user.dart';

void main() {
  const user = User(name: 'Alice', age: 25, email: 'alice@example.com');
  const role = Role.admin(adminLevel: 1, isActive: true);

  final older = user.copyWith(age: 26);
  final renamed = older.copyWith(name: 'Alicia');
  final withoutEmail = renamed.copyWith(email: null);

  final updatedRole = (role as Admin).copyWith(isActive: false);

  print(user);
  print(older);
  print(renamed);
  print(withoutEmail);
  print(
    'Admin Role: adminLevel=${updatedRole.adminLevel}, isActive=${updatedRole.isActive}',
  );
}
3
likes
0
points
269
downloads

Publisher

unverified uploader

Weekly Downloads

Package for automatic generation of copyWith methods in Dart classes using @CopyWith annotation.

Repository (GitHub)
View/report issues

Topics

#codegen #copy-with #code-generation #annotation

License

unknown (license)

Dependencies

analyzer, build, meta, source_gen

More

Packages that depend on easy_copy_with