navigatorCubit<T extends NavigatorCubit> method

T navigatorCubit<T extends NavigatorCubit>({
  1. bool listen = false,
})

Method that allows widgets to access a NavigatorCubit instance as long as their BuildContext contains a CubitNavigator instance.

If we want to access an instance of MyNavigatorCubit which was provided higher up in the widget tree we can do so via:

context.navigatorCubit<MyNavigatorCubit>();

Implementation

T navigatorCubit<T extends NavigatorCubit>({bool listen = false}) {
  return BlocProvider.of<T>(this, listen: listen);
}