copy_generator 0.1.3+1
copy_generator: ^0.1.3+1

Dart native

Automatically generating `copyWith` extensions code for classes with `@Copyable()` annotation.

  • Automatically generating copyWith extensions code for classes with @Copyable() annotation. This package supports copyWith with a null value.

For example #

//2 lines below are required
import 'package:copy/copy.dart'; // required
export 'package:copy/copy.dart'; // if you want to use ValueExtension

part 'basic_class.g.dart'; // required

// @Copyable is required
@Copyable()
class BasicClass {
  final String name;
  final int age;

  BasicClass({this.name, this.age});
}

Install #

dependencies:
  flutter:
    sdk: flutter

  copy: ^<newest>

dev_dependencies:
  flutter_test:
    sdk: flutter
  build_runner:
  copy_generator: ^<newest>

Run #

  • For build once

flutter pub run build_runner build --delete-conflicting-outputs

  • For automatically rebuild when the file changes

flutter pub run build_runner watch --delete-conflicting-outputs

Use #

BasicClass basic = BasicClass(name: 'name',age: 18);
basic = basic.copyWith(name: 'new name'.value);  // .value is Extension in ValueExtension
// basic should be ('new name',18)

basic = basic.copyWith(age: Value(null));
// basic should be ('new name',null)
1
likes
70
pub points
22%
popularity

Automatically generating `copyWith` extensions code for classes with `@Copyable()` annotation.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

tbm98.dev@gmail.com

License

BSD (LICENSE)

Dependencies

analyzer, build, copy, source_gen

More

Packages that depend on copy_generator