RefenaContainer class Initialization Introduction Riverpod

The RefenaContainer holds the state of all providers. Every provider state is initialized lazily and only once.

The RefenaContainer is used as ref

  • within provider builders and
  • within notifiers.

You can override a provider by passing overrides to the constructor. In this case, the state of the provider is initialized right away.

Implemented types
Implementers
Available Extensions

Constructors

RefenaContainer({PlatformHint platformHint = PlatformHint.unknown, List<ProviderOverride<BaseNotifier, dynamic>> overrides = const [], List<BaseProvider<BaseNotifier, dynamic>> initialProviders = const [], NotifyStrategy defaultNotifyStrategy = NotifyStrategy.equality, List<RefenaObserver> observers = const [], bool initImmediately = true})
Creates a RefenaContainer.

Properties

container RefenaContainer
Returns the backing container. The container exposes more advanced methods for edge cases.
no setteroverride
debugLabel String
A label to be used in debug messages and by the RefenaTracingPage.
no setteroverride
debugOwnerLabel String
Returns the owner of this Ref. Usually, this is a notifier or a widget. Used by Ref.redux to log the origin of the action.
no setteroverride
defaultNotifyStrategy NotifyStrategy
The default notify strategy
final
disposed bool
Whether the container has been disposed.
no setter
hashCode int
The hash code for this object.
no setterinherited
observer RefenaObserver?
The provided observer (e.g. for logging)
final
platformHint PlatformHint
The platform hint. This is used by the inspector_client to determine the host IP.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

anyNotifier<N extends BaseNotifier<T>, T>(BaseProvider<N, T> provider) → N
Returns the notifier of a NotifierProvider. This method can be used to avoid the constraint of NotifyableProvider. Useful for testing.
cleanupListeners() → void
Removes disposed listeners from all notifiers. This happens regularly, but you can call it manually if you want to to visualize the current state.
dispose<N extends BaseNotifier<T>, T>(BaseProvider<N, T> provider) → void
Disposes a provider. Be aware that streams (ref.stream) are closed also. You may call this method in the dispose method of a stateful widget. Note: The provider will be initialized again on next access.
override
disposeContainer() → void
Disposes the container itself. It will also dispose all providers. After calling this method, the container should not be used anymore.
disposeFamilyParam<N extends FamilyNotifier<dynamic, P>, P>(BaseProvider<N, dynamic> provider, P param) → void
Disposes the param of a family provider. While the ordinary dispose method disposes the whole provider, this method only disposes the param.
override
ensureOverrides() Future<void>
Awaiting this future will ensure that all overrides are initialized. Calling it multiple times is safe.
exists(BaseProvider<BaseNotifier, dynamic> provider) bool
Whether the provider is initialized. Usually, providers are initialized when you first access them. They are also initialized when you override them. They are getting disposed when you call Ref.dispose.
future<N extends AsyncNotifier<T>, T>(AsyncNotifierProvider<N, T> provider) Future<T>
Get the Future of an AsyncNotifierProvider.
override
getActiveNotifiers() List<BaseNotifier>
Returns all active notifiers. Remember: A provider is stateless. The notifier holds the state.
getActiveProviders() List<BaseProvider<BaseNotifier, dynamic>>
Returns all active providers. Remember: A provider is stateless. The notifier holds the state.
init() → void
Initializes the container.
internalDispose<N extends BaseNotifier<T>, T>(BaseProvider<N, T> provider, LabeledReference debugOrigin) → void
message(String message) → void
Emits a message to the observer. This might be handy if you use RefenaTracingPage.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifier<N extends BaseNotifier<T>, T>(NotifyableProvider<N, T> provider) → N
Returns the notifier of a NotifierProvider.
override
read<N extends BaseNotifier<T>, T, R>(Watchable<N, T, R> watchable) → R
Returns the actual value of a Provider.
override
redux<N extends BaseReduxNotifier<T>, T>(ReduxProvider<N, T> provider) Dispatcher<N, T>
Get a proxy class to dispatch actions to a ReduxNotifier.
override
set(ProviderOverride<BaseNotifier, dynamic> override) FutureOr<void>
Overrides a provider with a new value. This allows for overrides happening after the container was created.
stream<N extends BaseNotifier<T>, T>(BaseProvider<N, T> provider) Stream<NotifierEvent<T>>
Listen for changes to a provider.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited