https://github.com/smotastic/smartbok
Dart Annotation Processor for reducing boilerplate code
https://github.com/smotastic/smartbok
Last synced: 3 months ago
JSON representation
Dart Annotation Processor for reducing boilerplate code
- Host: GitHub
- URL: https://github.com/smotastic/smartbok
- Owner: smotastic
- Created: 2021-06-08T19:44:42.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-10T16:11:00.000Z (over 4 years ago)
- Last Synced: 2023-08-20T23:10:01.034Z (about 2 years ago)
- Language: Dart
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# smartbok
Dart Annotation Processor for reducing boilerplate code.
Heavily inspired by https://projectlombok.org/- [Installation](#installation)
- [Usage](#usage)# Installation
Add smartbok as a dev dependency.
```yaml
dev_dependencies:
smartbok:
```Run the generator
```console
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.
```dart
// model.dart
@CopyWith
class Model {
final String text;
final num number;
String someText;Model(this.text, {this.number});
}
``````dart
// 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;
}
}
```