model_notifier library Null safety

Package that defines and notifies the model.

To use, import package:model_notifier/model_notifier.dart.

Classes

AlwaysAliveProviderBase<Created, Listened>
A base class for providers that never disposes themselves. [...]
ApiCollectionModel<T>
Class that can retrieve data from the RestAPI and store it as a collection of value. [...]
ApiDocumentModel<T>
Class that can retrieve data from the RestAPI and store it as a document. [...]
ApiDynamicCollectionModel
ApiDynamicDocumentModel
AsyncData<T>
AsyncError<T>
AsyncLoading<T>
AsyncValue<T>
An utility for safely manipulating asynchronous data. [...]
AutoDisposeChangeNotifierProvider<T extends ChangeNotifier>
Creates a ChangeNotifier and subscribes to it. [...]
AutoDisposeChangeNotifierProviderFamily<T extends ChangeNotifier, A>
A class that allows building a ChangeNotifierProvider from an external parameter.
AutoDisposeFutureProvider<T>
A provider that asynchronously creates a single value. [...]
AutoDisposeFutureProviderFamily<T, A>
A class that allows building a FutureProvider from an external parameter.
AutoDisposeModelProvider<T extends Model>
Builds a AutoDisposeModelProvider.
AutoDisposeModelProviderBuilder
Builds a AutoDisposeModelProvider.
AutoDisposeModelProviderFamily<T extends Model, A>
A group of providers that builds their value from an external parameter. [...]
AutoDisposeModelProviderFamilyBuilder
Builds a AutoDisposeModelProviderFamily.
AutoDisposeProvider<T>
A provider that exposes a read-only value. [...]
AutoDisposeProviderBase<Created, Listened>
A base class for providers that destroy their state when no-longer listened. [...]
AutoDisposeProviderElement<Created, Listened>
The ProviderElement of an AutoDisposeProviderBase.
AutoDisposeProviderFamily<T, A>
A class that allows building a Provider from an external parameter.
AutoDisposeProviderReference
A ProviderReference for providers that are automatically destroyed when no-longer used. [...]
AutoDisposeStateNotifierProvider<T extends StateNotifier<Object?>>
Creates a StateNotifier and expose its current state. [...]
AutoDisposeStateNotifierProviderFamily<T extends StateNotifier<Object?>, A>
A class that allows building a StateNotifierProvider from an external parameter.
AutoDisposeStateNotifierStateProvider<T>
A provider that exposes the state of a StateNotifier. [...]
AutoDisposeStateProvider<T>
A provider that expose a value which can be modified from outside. [...]
AutoDisposeStateProviderFamily<T, A>
A class that allows building a StateProvider from an external parameter.
AutoDisposeStreamProvider<T>
Creates a stream and expose its latest event. [...]
AutoDisposeStreamProviderFamily<T, A>
A class that allows building a StreamProvider from an external parameter.
ChangeNotifierListener<T extends ChangeNotifier>
Widget that listens for ChangeNotifiers and rebuilds the widgets inside when there is an update.
ChangeNotifierProvider<T extends ChangeNotifier>
Creates a ChangeNotifier and subscribes to it. [...]
ChangeNotifierProviderFamily<T extends ChangeNotifier, A>
A class that allows building a ChangeNotifierProvider from an external parameter.
CollectionMockModel<T, Result>
Abstract class for creating mocks for collections. [...]
Config
Class that handles the app config. [...]
Consumer
Build a widget tree while listening to providers. [...]
ConsumerWidget
A StatelessWidget that can listen to providers. [...]
DocumentMockModel<T, Result>
Abstract class for creating mocks for documents. [...]
DocumentModel<T>
Abstract class for the document model. [...]
Family<Created, Listened, Param, Ref extends ProviderReference, P extends RootProvider<Created, Listened>>
A base class for all *Family variants of providers.
FutureProvider<T>
A provider that asynchronously creates a single value. [...]
FutureProviderFamily<T, A>
A class that allows building a FutureProvider from an external parameter.
Hook<R>
Hook is similar to a StatelessWidget, but is not associated to an Element. [...]
HookBuilder
A HookWidget that defer its build to a callback
HookState<R, T extends Hook<R>>
The logic and internal state for a HookWidget
HookWidget
A Widget that can use Hook [...]
ListenedModel<T, Result extends Model<T>>
A model class for listening for and retrieving data.
ListModel<T extends Listenable>
A model that can be treated as a list. [...]
ListNotifier<T extends Listenable>
This is a ChangeNotifier class that can be handled as a list. [...]
LocalCollectionModel<T extends LocalDocumentModel>
Base class for holding and manipulating data from a local database as a collection of LocalDocumentModel. [...]
LocalDocumentModel<T>
Base class for holding and manipulating data from a local database as a document of T. [...]
LocalDynamicCollectionModel
Specify the path and use Map<String, dynamic> to hold the data LocalCollectionModel. [...]
LocalDynamicDocumentModel
Specify the path and use Map<String, dynamic> to hold the data LocalDocumentModel. [...]
Localize
Class to translate. [...]
MapModel<T>
A model that can be treated as a map. [...]
MapNotifier<T>
This is a ChangeNotifier class that can be handled as a map. [...]
Model<T>
You can create a Model based on a ChangeNotifier.
ModelProvider<T extends Model>
Provider for handling the Model class. [...]
ModelProviderBuilder
Builds a ModelProvider.
ModelProviderFamily<T extends Model, A>
A class that allows building a ModelProvider from an external parameter.
ModelProviderFamilyBuilder
Builds a ModelProviderFamily.
Override
An object used by ProviderContainer/ProviderScope to override the behavior of a provider/family for part of the application. [...]
Prefs
Save and load data locally. [...]
Provider<T>
A provider that exposes a read-only value. [...]
ProviderBase<Created, Listened>
A base class for all providers.
ProviderContainer
An object that stores the state of the providers and allows overriding the behavior of a specific provider. [...]
ProviderElement<Created, Listened>
An internal class that handles the state of a provider. [...]
ProviderFamily<T, A>
A class that allows building a Provider from an external parameter.
ProviderListenable<Listened>
A base class for all providers, used to consume a provider. [...]
ProviderListener<T>
A widget that allows listening to a provider. [...]
ProviderObserver
An object that listens to the changes of a ProviderContainer. [...]
ProviderReference
An object used by providers to interact with other providers and the life-cycles of the application. [...]
ProviderScope
A widget that stores the state of providers. [...]
ProviderSubscription<Listened>
An object that allows watching the state of a provider. [...]
ReferenceListModel<T extends Listenable>
This model creates a new provider by registering multiple providers together in the build method and spitting out the List data.
ReferenceMapModel<T>
This model creates a new provider by registering multiple providers together in the build method and spitting out the Map data.
ReferenceModel<T>
This model creates a new provider by registering multiple providers together in the build method and spitting out the T data.
RootProvider<Created, Listened>
A base class for non-scoped providers. [...]
ScopedProvider<Listened>
A provider that may behave differently for a specific part of the application. [...]
StateController<T>
A StateNotifier that allows modifying its state from outside. [...]
StatefulHookWidget
A StatefulWidget that can use Hook [...]
StateNotifier<T>
An observable class that stores a single immutable state. [...]
StateNotifierProvider<T extends StateNotifier<Object?>>
Creates a StateNotifier and expose its current state. [...]
StateNotifierProviderFamily<T extends StateNotifier<Object?>, A>
A class that allows building a StateNotifierProvider from an external parameter.
StateNotifierStateProvider<T>
A provider that exposes the state of a StateNotifier. [...]
StateProvider<T>
A provider that expose a value which can be modified from outside. [...]
StateProviderFamily<T, A>
A class that allows building a StateProvider from an external parameter.
Store<State, Action>
A state holder that allows mutations by dispatching actions.
StoredModel<T, Result extends Model<T>>
Abstract class that defines methods for reading and writing data.
StreamProvider<T>
Creates a stream and expose its latest event. [...]
StreamProviderFamily<T, A>
A class that allows building a StreamProvider from an external parameter.
UncontrolledProviderScope
Expose a ProviderContainer to the widget tree. [...]
UserStateChangedCallback
Callback class to be called when the user's state is changed.
ValueModel<T>
Model which only stores one value. [...]

Mixins

HookElement
An Element that uses a HookWidget as its configuration.
ListModelMixin<T>
This is a mix-in that allows you to treat a model as a List. [...]
LocalDocumentMetaMixin<T>
Mix-in that completes the document metadata (time, UID, etc.) on Save. [...]
LocatorMixin
A mixin that adds service location capability to an object. [...]
MapModelMixin<T>
A mix-in that allows you to use a model as a map. [...]

Extensions

AsyncValueExtensions
AutoDisposeStateFamilyX
Overrides overrideWithProvider for StateProvider.autoDispose.family.
AutoDisposeStateNotifierStateProviderX
Adds state to StateNotifierProvider.autoDispose.
BuildContextX
Adds context.read
ChangeNotifierMapExtensions
ColorExtensions
DateTimeExtension
DoubleExtensions
DurationExtension
FamilyX
Implements overrideWithProvider for families. [...]
IntExtensions
IterableExtensions
ListExtensions
List extension methods.
MapExtensions
NullableAsyncValueExtensions
NullableDoubleExtensions
NullableIntExtensions
NullableIterableExtensions
NullableMapExtensions
NullableObjectExtensions
NullableSetExtensions
NullableStringExtensions
NullableValueIterableExtensions
RandomExtension
SetExtensions
StateFamilyX
Overrides overrideWithProvider for StateProvider.family.
StateNotifierStateProviderX
Adds state to StateNotifierProvider.autoDispose.
StringExtensions

Constants

useTextEditingController → const _TextEditingControllerHookCreator
Creates a TextEditingController, either via an initial text or an initial TextEditingValue. [...]
_TextEditingControllerHookCreator()

Properties

apiCollectionProvider ModelProviderFamily<ApiDynamicCollectionModel, String>
final
apiDocumentProvider ModelProviderFamily<ApiDynamicDocumentModel, String>
final
debugHotReloadHooksEnabled bool
Wether to behave like in release mode or allow hot-reload for hooks. [...]
read / write
localCollectionProvider ModelProviderFamily<LocalDynamicCollectionModel, String>
Base class for holding and manipulating data from a local database as a collection of LocalDocumentModel. [...]
final
localDocumentProvider ModelProviderFamily<LocalDynamicDocumentModel, String>
Base class for holding and manipulating data from a local database as a document of T. [...]
final
uuid String
Get UUID. [...]
read-only

Functions

generateCode(int length, {int seed = 0, String charSet = "23456789abcdefghjkmnpqrstuvwxy"}) String
Create a code of length length randomly for id. [...]
jsonDecodeAsList<T extends Object>(String json, [List<T> defaultValue = const []]) List<T>
json decoding. [...]
jsonDecodeAsMap<T extends Object>(String json, [Map<String, T> defaultValue = const {}]) Map<String, T>
json decoding. [...]
openURL(String url) Future<void>
Open a new external url.
readProvider<Result>(ProviderBase<Object?, Result> provider) → Result
Load the provider. [...]
use<R>(Hook<R> hook) → R
Register a Hook and returns its value [...]
useAnimation<T>(Animation<T> animation) → T
Subscribes to an Animation and return its value. [...]
useAnimationController({Duration? duration, String? debugLabel, double initialValue = 0, double lowerBound = 0, double upperBound = 1, TickerProvider? vsync, AnimationBehavior animationBehavior = AnimationBehavior.normal, List<Object?>? keys}) AnimationController
Creates an AnimationController automatically disposed. [...]
useContext() BuildContext
Obtain the BuildContext of the building HookWidget.
useEffect(Dispose? effect(), [List<Object?>? keys]) → void
Useful for side-effects and optionally canceling them. [...]
useFocusNode({String? debugLabel, FocusOnKeyCallback? onKey, bool skipTraversal = false, bool canRequestFocus = true, bool descendantsAreFocusable = true}) FocusNode
Creates and dispose of a FocusNode. [...]
useFuture<T>(Future<T>? future, {required T initialData, bool preserveState = true}) AsyncSnapshot<T>
Subscribes to a Future and return its current state in an AsyncSnapshot. [...]
useIsMounted() IsMounted
Returns an IsMounted object that you can use to check if the State is mounted. [...]
useListenable<T extends Listenable>(T listenable) → T
Subscribes to a Listenable and mark the widget as needing build whenever the listener is called. [...]
useMemoized<T>(T valueBuilder(), [List<Object?> keys = const <Object>[]]) → T
Cache the instance of a complex object. [...]
usePageController({int initialPage = 0, bool keepPage = true, double viewportFraction = 1.0, List<Object?>? keys}) PageController
Creates and disposes a PageController. [...]
usePrevious<T>(T val) → T?
Returns the previous value passed to usePrevious (from the previous widget build).
useProvider<T>(ProviderListenable<T> provider) → T
A hook that listens to a provider and returns its current value. [...]
useReassemble(VoidCallback callback) → void
Runs the callback on every hot reload similar to reassemble in the Stateful widgets [...]
useReducer<State, Action>(Reducer<State, Action> reducer, {required State initialState, required Action initialAction}) Store<State, Action>
An alternative to useState for more complex states. [...]
useScrollController({double initialScrollOffset = 0.0, bool keepScrollOffset = true, String? debugLabel, List<Object?>? keys}) ScrollController
Creates and disposes a ScrollController. [...]
useSingleTickerProvider({List<Object?>? keys}) TickerProvider
Creates a single usage TickerProvider. [...]
useState<T>(T initialData) ValueNotifier<T>
Creates a variable and subscribes to it. [...]
useStream<T>(Stream<T>? stream, {required T initialData, bool preserveState = true}) AsyncSnapshot<T>
Subscribes to a Stream and return its current state in an AsyncSnapshot. [...]
useStreamController<T>({bool sync = false, VoidCallback? onListen, VoidCallback? onCancel, List<Object?>? keys}) StreamController<T>
Creates a StreamController automatically disposed. [...]
useTabController({required int initialLength, TickerProvider? vsync, int initialIndex = 0, List<Object?>? keys}) TabController
Creates and disposes a TabController. [...]
useValueChanged<T, R>(T value, R? valueChange(T oldValue, R? oldResult)) → R?
Watches a value and calls a callback whenever the value changed. [...]
useValueListenable<T>(ValueListenable<T> valueListenable) → T
Subscribes to a ValueListenable and return its value. [...]
useValueNotifier<T>(T initialData, [List<Object?>? keys]) ValueNotifier<T>
Creates a ValueNotifier automatically disposed. [...]

Typedefs

ConsumerBuilder(BuildContext context, ScopedReader watch, Widget? child) Widget
A function that can also listen to providers [...]
Create<T, Ref extends ProviderReference>(Ref ref) → T
A callback used by providers to create the value exposed. [...]
Dispose() → void
A function called when the state of a widget is destroyed.
ErrorListener(Object error, StackTrace? stackTrace) → void
A callback that can be passed to StateNotifier.onError. [...]
IsMounted() bool
Used by useIsMounted to allow widgets to determine if the widget is still in the widget tree or not.
Listener<T>(T state) → void
A listener that can be added to a StateNotifier using StateNotifier.addListener. [...]
Locator() → T
A function that allows obtaining other objects. [...]
OnProviderChange<T>(BuildContext context, T value) → void
A function that can react to changes on a provider [...]
Reader(RootProvider<Object?, T> provider) → T
A function that reads the state of a provider.
Reducer<State, Action>(State state, Action action) → State
Composes an Action and a State to create a new State. [...]
RemoveListener() → void
A callback that can be used to remove a listener added with StateNotifier.addListener. [...]
ScopedCreate<T>(ScopedReader watch) → T
The function that ScopedProviders uses to create their state.
ScopedReader(ProviderBase<Object?, T> provider) → T
A function that can both read a ScopedProvider, normal providers and a myProvider.select(..)

Exceptions / Errors

CircularDependencyError
An error thrown when a call to ProviderReference.read/ProviderReference.watch leads to a provider depending on itself. [...]
DependencyNotFoundException<T>
Thrown when tried to call LocatorMixin.read<T>(), but the T was not found.s
ProviderException
Encapulates an exception thrown while building a provider. [...]