of<T extends RxBlocTypeBase?> static method
Method that allows widgets to access a bloc
instance as
long as their BuildContext
contains a RxBlocProvider instance.
If we want to access an instance of BlocA
which was
provided higher up in the widget tree
we can do so via:
RxBlocProvider.of<BlocA>(context)
Implementation
static T of<T extends RxBlocTypeBase?>(BuildContext context) {
try {
return Provider.of<T>(context, listen: false);
} on ProviderNotFoundException catch (_) {
throw FlutterError(
"""
RxBlocProvider.of() called with a context that does not contain a Bloc of type $T.
No ancestor could be found starting from the context that was passed to RxBlocProvider.of<$T>().
This can happen if:
1. The context you used comes from a widget above the RxBlocProvider.
2. You used MultiRxBlocProvider and didn\'t explicity provide the RxBlocProvider types.
Good: RxBlocProvider<$T>(create: (context) => $T())
Bad: RxBlocProvider(create: (context) => $T()).
The context used was: $context
""",
);
}
}