0 purchases
smartbok
smartbok #
Dart Annotation Processor for reducing boilerplate code.
Heavily inspired by https://projectlombok.org/
Installation
Usage
Installation #
Add smartbok as a dev dependency.
dev_dependencies:
smartbok:
copied to clipboard
Run the generator
dart run build_runner build
flutter packages pub run build_runner build
// or watch
flutter packages pub run build_runner watch
copied to clipboard
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});
}
copied to clipboard
// 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;
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.