Provider<T extends Object>.value constructor

Provider<T extends Object>.value(
  1. T value, {
  2. Key? key,
  3. void disposer(
    1. T
    )?,
  4. bool updateShouldNotify(
    1. T previous,
    2. T current
    )?,
  5. Widget? child,
})

Provide a value to all descendants.

updateShouldNotify is a callback called whenever InheritedWidget.updateShouldNotify is called. It should return false when there's no need to update its dependents. Default value of updateShouldNotify is returning true if old value is not equal to current value.

The disposer will called when State of Provider is removed from the tree permanently (State.dispose called), or whenever the widget configuration changes with difference value (State.didUpdateWidget called).

Implementation

factory Provider.value(
  T value, {
  Key? key,
  void Function(T)? disposer,
  bool Function(T previous, T current)? updateShouldNotify,
  Widget? child,
}) {
  assert(value != null);
  return _ValueProvider<T>(
    value: value,
    disposer: disposer,
    updateShouldNotify: updateShouldNotify ?? _notEquals,
    child: child,
    key: key,
  );
}