addPage<TBloc> method
void
addPage<TBloc>({
- required IocContainer container,
- required String name,
- required TBloc initialState(
- Object? arguments
- required Widget pageBody(
- BuildContext context
- required void buildBloc(
- BlocBuilder<
TBloc> blocBuilder, - IocContainer container
- BlocBuilder<
- bool onPopPage()?,
- BlocEvent? initialEvent,
Add a page for routing. initialEvent
allows you to send an event to the
Bloc when the page first loads. Use onPop to cancel pops or clean up
the pageScope. Use the blocBuilder to add async and sync bloc handlers to
deal with UI changes
Implementation
//ignore: long-parameter-list
void addPage<TBloc>({
required IocContainer container,
required String name,
required TBloc Function(Object? arguments) initialState,
required Widget Function(BuildContext context) pageBody,
required void Function(
BlocBuilder<TBloc> blocBuilder,
IocContainer container,
)
buildBloc,
bool Function(
Route<dynamic> route,
// ignore: avoid_annotating_with_dynamic
dynamic result,
PageArgs<dynamic> pageArgs,
)?
onPopPage,
BlocEvent? initialEvent,
}) {
_addPage(
name,
PageBuilder(
initialEvent: initialEvent,
builder: pageBody,
onPopPage: onPopPage,
blocBuilder: () {
final blocBuilder = BlocBuilder<TBloc>(initialState);
buildBloc(blocBuilder, container);
return blocBuilder;
},
),
);
}