bloc property

B bloc
latefinal

The bloc instance for this page, automatically initialized with dependencies.

Example usage in a page:

FloatingActionButton(
  onPressed: () {
    // Using bloc in BaseBlocPageState
    bloc.add(CounterEvent.increment());

    // Using bloc in BaseCubitPageState
    bloc.increment();
  },
  child: Icon(Icons.add),
)

Note: The bloc is typed as B which can be either:

The bloc is automatically disposed when the page is disposed.

Implementation

late final B bloc = di<B>() as dynamic
  ..commonBloc = commonBloc
  ..navigator = navigator;