rx_notifier_generator 1.0.2 copy "rx_notifier_generator: ^1.0.2" to clipboard
rx_notifier_generator: ^1.0.2 copied to clipboard

Generate RxNotifier getter and setter. Use annotations @store and @rx

rx_notifier_generator #

Generate RxNotifier getter and setter. Use annotations @store and @rx;

OPTIONAL Code generator #

If you prefer a leaner syntax for RxNotifier objects, use code generation with build_runner.

  1. Add the rx_notifier_generator and build_runner packages to dev_dependencies.

dependencies:
  rx_notifier: <current-version>

dev_dependencies:
  rx_notifier_generator: <current-version>
  build_runner: <current-version>
  1. Use the @RxStore annotation on the class and @RxValue on the properties.
part 'app_store.g.dart';

@RxStore()
abstract class _AppStore {
  @RxValue()
  int count = 0;

  @RxValue()
  String name = 'Barney';
}
  1. Run the build runner:
dart pub run build_runner --delete-conflicting-outputs
  1. Just use:
final appStore = AppStore();

rxObserver((){
  print(appStore.count);
});

appStore.count++; // update

  1. The class that will be annotated with @RxStore must be abstract and private. The generator will start a public instance with transparent RxNotifier.

  2. Properties with @RxValue must be mutable and public.

0
likes
135
points
2
downloads

Publisher

unverified uploader

Weekly Downloads

Generate RxNotifier getter and setter. Use annotations @store and @rx

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, build, rx_notifier_annotation, source_gen

More

Packages that depend on rx_notifier_generator