maac_mvvm_generator 0.0.3
maac_mvvm_generator: ^0.0.3 copied to clipboard
Automates maac_mvvm setup by generating extensions with stream data getters for annotated fields.
maac_mvvm_generator #
maac_mvvm_generator is a powerful code generator designed for the maac_mvvm package.
Description #
maac_mvvm_generator streamlines the development process by automatically generating necessary code, thereby significantly reducing boilerplate when working with the maac_mvvm package.
Features #
- Reduces boilerplate code for creating ViewModel with maac_mvvm components.
- Easy integration with the maac_mvvm package.
Getting started #
- Add
maac_mvvm_annotationto yourdependencies:
flutter pub add maac_mvvm_annotation
- Add
maac_mvvm_generatorto yourdev_dependencies:
flutter pub add dev:maac_mvvm_generator
Usage #
First let change current code :
import 'package:maac_mvvm/maac_mvvm.dart';
class ExampleViewModel extends ViewModel {
late final _count = 0.mutableData(this);
StreamData<int> get count => _count.streamData;
void incrementCounter() => _count.postValue(_count.data + 1);
}
to
import 'package:maac_mvvm_annotation/maac_mvvm_annotation.dart';
import 'package:maac_mvvm/maac_mvvm.dart';
part 'example_view_model.g.dart';
@BindableViewModel()
class ExampleViewModel extends ViewModel {
@Bind()
late final _count = 0.mutableData(this);
void incrementCounter() => _count.postValue(_count.data + 1);
}
then run :
flutter pub run build_runner build --delete-conflicting-outputs
The StreamData<int> get count => _count.streamData; will be generated in example_view_model.g.dart.