Closed magician20 closed 2 years ago
@magician20 yes, change EmptyRouterPage to your own widget that accepts the needed args.
@Milad-Akarie Sorry for my bad question but what about accessing BookDetailsPage? As you can see below the Wrapping Class code, I can open BooksPage but then I can't open BookDetailsPage. I don't know how to make AutoRouter differentiate the two routes/paths.
///I'm trying to pass scaffoldKey to BooksPage
@override
Widget build(BuildContext context) {
// AutoRouter is required to render sub-routes
return AutoRouter(builder: (context, content) => BooksPage(scaffoldKey: scaffoldKey),);
}
Thanks for reply.
@magician20 the content coming from router is the rendered stack and you're replacing it with just one page. just remove the builder from AutoRouter and just return the AutoRouter() widget as is
@Milad-Akarie Thanks for reply I did as you mention and it work (can access detail page for each book) but, I got two problem
1-scaffoldKey object never passed down to BooksPage so I wasn't able to open or close drawer. 2-Mobile app lose BooksPage state when I navigate to different page by drawer ,despite work fine on web, so how can WrapperRouterPage can pass the argument to BooksPage ?
class WrapperRouterPage extends StatelessWidget {
///this key handle drawer state open/close
final GlobalKey
@override Widget build(BuildContext context) { // AutoRouter is required to render sub-routes return AutoRouter(/builder: (context, content) => BooksPage(scaffoldKey: scaffoldKey),/); } }
AutoTabsScaffold( //scaffoldKey: _scaffoldKey,//not working routes: [ BooksRouter(scaffoldKey: _scaffoldKey), ArchiveRoute(), SettingsRoute(), AboutRoute() ],
Hi, I think you have to push a BooksRouter
with a BooksRoute
as its child.
context.push(
BooksRouter(
children:[
BooksRoute(
scaffoldKey: scaffoldKey,
)
]
)
);
@wferem1 I don't think I can use that with AutoTabsScaffold
@Milad-Akarie @wferem1 Any help here with AutoTabsScaffold & Drawer open & Close. Problem how sub tree widget like BooksPage can accesses the drawer global key of HomePage top widget ?
@Milad-Akarie I solved By using state management (ex: Cubit) so i can be able to pass scaffoldKey to sub widget inside the nested route of Books. (is that good way ? or maybe if we have a away to be able to pass value to constructor of EmptyRouterPage and below widget can access them)
My question how to pass an argument (not paramter that will appear on the url ) from HomePage Class that use AutoTabsScaffold to the BooksPage Class.