Provider<T extends Object>.factory constructor

Provider<T extends Object>.factory(
  1. T factory(
    1. BuildContext
    ), {
  2. Key? key,
  3. void disposer(
    1. T
    )?,
  4. Widget? child,
})

Provide a value to all descendants. The value created on first access by calling factory.

The disposer will called when State of Provider is removed from the tree permanently (State.dispose called).

Implementation

factory Provider.factory(
  T Function(BuildContext) factory, {
  Key? key,
  void Function(T)? disposer,
  Widget? child,
}) {
  assert(factory != null);
  return _FactoryProvider<T>(
    key: key,
    factory: factory,
    disposer: disposer,
    child: child,
  );
}