useNotifier<V> method

ValueNotifier<V> useNotifier<V>({
  1. required String key,
  2. required V initialValue,
})

Retrieves an existing ValueNotifier or creates a new one.

key: A unique string key to identify the ValueNotifier. initialValue: The initial value of the ValueNotifier.

Returns a ValueNotifier associated with the given key.

Implementation

ValueNotifier<V> useNotifier<V>({
  required String key,
  required V initialValue,
}) {
  return _getOrCreate(
      key: key,
      create: () => ValueNotifier<V>(initialValue),
      disposeHandler: (notifier) async => notifier.dispose());
}