BlocProvider<T extends StateStreamableSource<Object?>>.value constructor

const BlocProvider<T extends StateStreamableSource<Object?>>.value({
  1. required T value,
  2. Key? key,
  3. Widget? child,
})

Takes a value and a child which will have access to the value via BlocProvider.of(context). When BlocProvider.value is used, the Bloc or Cubit will not be automatically closed. As a result, BlocProvider.value should only be used for providing existing instances to new subtrees.

A new Bloc or Cubit should not be created in BlocProvider.value. New instances should always be created using the default constructor within the Create function.

BlocProvider.value(
  value: BlocProvider.of<BlocA>(context),
  child: ScreenA(),
);

Implementation

const BlocProvider.value({
  required T value,
  Key? key,
  this.child,
})  : _value = value,
      _create = null,
      lazy = true,
      super(key: key, child: child);