smartbok 1.0.0 copy "smartbok: ^1.0.0" to clipboard
smartbok: ^1.0.0 copied to clipboard

Dart Annotation Processor for automatically generating boilerplate code, such as copyWith Methods for Models

smartbok #

Dart Annotation Processor for reducing boilerplate code. Heavily inspired by https://projectlombok.org/

Installation #

Add smartbok as a dev dependency.

dev_dependencies:
  smartbok:

Run the generator

dart run build_runner build
flutter packages pub run build_runner build
// or watch
flutter packages pub run build_runner watch

Usage #

CopyWith #

Generates an extension for the annotated class, with a generated $copyWith Method.

// model.dart
@CopyWith
class Model {
    final String text;
    final num number;
    String someText;

    Model(this.text, {this.number});
}
// model.g.dart
extension ModelCopyWithExtension on Model {
  Model $copyWith({String? text, num? number, String? someText}) {
    final model = Model(
        text ?? this.text,
        number: number ?? this.number
    );
    model.someText = someText ?? this.someText;
    return model;
  }
}
0
likes
110
pub points
0%
popularity

Publisher

unverified uploader

Dart Annotation Processor for automatically generating boilerplate code, such as copyWith Methods for Models

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

analyzer, build, code_builder, source_gen

More

Packages that depend on smartbok