ValueListenableProvider<T> constructor

  1. @Deprecated('Will be removed in 5.0.0. ' 'Instead use a StatefulWidget and manually create/dispose the ValueNotifier, ' 'then use ValueListenableProvider.value()')
ValueListenableProvider<T>(
  1. {Key key,
  2. @required Create<ValueNotifier<T>> create,
  3. UpdateShouldNotify<T> updateShouldNotify,
  4. bool lazy,
  5. TransitionBuilder builder,
  6. Widget child}
)

Creates a ValueNotifier using create and automatically dispose it when ValueListenableProvider is removed from the tree.

create must not be null.

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.

See also:

Implementation

@Deprecated(
  'Will be removed in 5.0.0. '
  'Instead use a StatefulWidget and manually create/dispose the ValueNotifier, '
  'then use ValueListenableProvider.value()',
)
ValueListenableProvider({
  Key key,
  @required Create<ValueNotifier<T>> create,
  UpdateShouldNotify<T> updateShouldNotify,
  bool lazy,
  TransitionBuilder builder,
  Widget child,
}) : super(
        key: key,
        create: create,
        lazy: lazy,
        builder: builder,
        updateShouldNotify: updateShouldNotify,
        startListening: _startListening(),
        dispose: _dispose,
        child: child,
      );