Provider<T> constructor

Provider<T>(
  1. {Key key,
  2. @required Create<T> create,
  3. Dispose<T> dispose,
  4. bool lazy,
  5. TransitionBuilder builder,
  6. Widget child}
)

Creates a value, store it, and expose it to its descendants.

The value can be optionally disposed using dispose callback. This callback which will be called when Provider is unmounted from the widget tree.

Implementation

Provider({
  Key key,
  @required Create<T> create,
  Dispose<T> dispose,
  bool lazy,
  TransitionBuilder builder,
  Widget child,
})  : assert(create != null),
      super(
        key: key,
        lazy: lazy,
        builder: builder,
        create: create,
        dispose: dispose,
        debugCheckInvalidValueType: kReleaseMode
            ? null
            : (T value) =>
                Provider.debugCheckInvalidValueType?.call<T>(value),
        child: child,
      );