Skip to content

Dart Annotation Processor for reducing boilerplate code

Notifications You must be signed in to change notification settings

smotastic/smartbok

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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;
  }
}

About

Dart Annotation Processor for reducing boilerplate code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages