isActive method
Returns whether this application context is currently active.
An active context has been successfully refreshed and is fully operational. This is the normal running state of a context between refresh and close.
State Transitions:
- false → true: When
refresh()
completes successfully - true → false: When
close()
is called - Irreversible: Once false, cannot become true again
Usage:
if (context.isActive()) {
// Safe to use context and retrieve pods
final service = context.getPod<MyService>();
service.doSomething();
} else {
throw StateError('Context is not active');
}
Implementation
@override
bool isActive() => _isActive;