ViewModelContextService mixin
Mixin that provides organic context access to ViewModels
Add this to ViewModel<T> and AsyncViewModelImpl<T> base classes
No setup required - context is automatically available when builders are active
- Mixin applications
Properties
- context → BuildContext?
-
Get current BuildContext if available
Automatically provided when any ReactiveBuilder is mounted
no setter
- globalContext → BuildContext?
-
Get global BuildContext directly (bypassing specific ViewModel context)
This context is persistent and remains available throughout app lifecycle
Ideal for Riverpod/Provider migration where context stability is needed
no setter
- hasContext → bool
-
Check if context is currently available
Useful for conditional context-dependent operations
no setter
- hasGlobalContext → bool
-
Check if global context is available
Global context is set via ReactiveNotifier.initContext()
and persists throughout the app lifecycle regardless of builder state
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
requireContext(
[String? operation]) → BuildContext - Get context with descriptive error if unavailable Use when context is absolutely required for the operation
-
requireGlobalContext(
[String? operation]) → BuildContext - Get global context with descriptive error if unavailable Use when global context is absolutely required (e.g., Riverpod migration)
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited