ease_annotation 0.2.0 copy "ease_annotation: ^0.2.0" to clipboard
ease_annotation: ^0.2.0 copied to clipboard

Annotations for ease_state_helper Flutter state management library. Use @Ease() to mark StateNotifier classes for code generation.

example/example.dart

import 'package:ease_annotation/ease_annotation.dart';

// Use @Ease() annotation to mark StateNotifier classes for code generation.
// After running `dart run build_runner build`, providers and context
// extensions will be generated automatically.

// Example 1: Global provider (included in EaseScope)
@Ease()
class CounterViewModel {
  // This would extend StateNotifier<int> in a real app
  int state = 0;

  void increment() => state++;
  void decrement() => state--;
}

// Example 2: Local provider (manually placed in widget tree)
@Ease(local: true)
class FormViewModel {
  // This would extend StateNotifier<FormState> in a real app
  // Local providers are NOT included in EaseScope
  // You must manually add FormViewModelProvider to your widget tree
}

void main() {
  // The @Ease() annotation is processed at build time.
  // Run: dart run build_runner build
  //
  // This generates:
  // - CounterViewModelProvider widget
  // - context.counterViewModel (watch, rebuilds on change)
  // - context.readCounterViewModel() (read, no rebuild)
  // - context.selectCounterViewModel((s) => s.field) (granular rebuild)
}
0
likes
160
points
235
downloads

Publisher

verified publisherwidget-lab.dev

Weekly Downloads

Annotations for ease_state_helper Flutter state management library. Use @Ease() to mark StateNotifier classes for code generation.

Repository (GitHub)
View/report issues
Contributing

Topics

#state-management #annotation #code-generation

Documentation

API reference

License

MIT (license)

More

Packages that depend on ease_annotation