Provider<T>.value constructor

Provider<T>.value({
  1. Key? key,
  2. required T value,
  3. UpdateShouldNotify<T>? updateShouldNotify,
  4. TransitionBuilder? builder,
  5. Widget? child,
})

Expose an existing value without disposing it.

updateShouldNotify can optionally be passed to avoid unnecessarily rebuilding dependents when Provider is rebuilt but value did not change.

Defaults to (previous, next) => previous != next. See InheritedWidget.updateShouldNotify for more information.

Implementation

Provider.value({
  Key? key,
  required T value,
  UpdateShouldNotify<T>? updateShouldNotify,
  TransitionBuilder? builder,
  Widget? child,
})  : assert(() {
        Provider.debugCheckInvalidValueType?.call<T>(value);
        return true;
      }()),
      super.value(
        key: key,
        builder: builder,
        value: value,
        updateShouldNotify: updateShouldNotify,
        child: child,
      );