framework/generator/generator library
Air Framework Code Generation INNOV-010: Generación de Código con Build Runner
This library provides annotations and base classes for code generation.
Quick Start
- Add dependencies to pubspec.yaml:
dev_dependencies:
build_runner: ^2.4.0
air_generator: ^1.0.0
- Create a state with annotations:
import 'package:air_framework/generator.dart';
part 'counter_state.g.dart';
@GenerateState('counter')
class CounterState extends _CounterState {
@Pulse()
void increment();
@Pulse()
void decrement();
@Flow()
int count = 0;
}
- Run code generation:
flutter pub run build_runner build
Available Annotations
@GenerateState(moduleId)- Mark a class as an Air state@Pulse()- Mark a method as a pulse/signal@Flow()- Mark a field as a reactive flow@GenerateModule(moduleId)- Mark a class as an Air module@Route(path)- Mark a method as a route@GenerateEvent()- Mark a class as an Air event@Inject()- Mark a field for dependency injection@Computed(deps)- Mark a getter as a computed state
Classes
- Computed
- Annotation to mark a computed state
- GeneratedAirState
- Base class for generated state classes INNOV-010: Code Generation Support
- GeneratedAppModule
- Base class for generated module classes
- GeneratedEvent
- Base class for generated events
- GeneratedFlowsRegistry
- Registry for generated flows (state keys)
- GeneratedPulsesRegistry
- Registry for generated pulses
- GenerateEvent
- Annotation to mark a class as an Air event
- GenerateModule
- Annotation to mark a class as an Air module
- GenerateState
- Annotation to mark a class as an Air state
- Inject
- Annotation to inject a dependency
- Pulse
- Annotation to mark a method as a pulse (signal/action)
- Route
- Annotation to mark a method as a route
- StateFlow
- Annotation to mark a field as a flow (reactive state)
Mixins
- GeneratedInjection
- Mixin for automatic dependency injection