copy_generator 0.1.3+1 copy "copy_generator: ^0.1.3+1" to clipboard
copy_generator: ^0.1.3+1 copied to clipboard

discontinuedreplaced by: freezed

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
20
pub points
0%
popularity

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

Dependencies

analyzer, build, copy, source_gen

More

Packages that depend on copy_generator