routemaster
routemaster copied to clipboard
What is the best way to use Pageless route without context?
To show a dialog, I think I need to directly use Navigator class to push Route class like bellow.
final dialogRoute = DialogRoute(
context: context,
builder: (context) => SizedBox(
child: Center(
child: CircularProgressIndicator(),
),
),
);
Navigator.of(context).push(dialogRoute);
And here I need a context to pass to Navigator.of
.
In my previous app, I get a context from Navigator key, but there is no way to set navigator key in routemaster.
Is there any way to solve this situation?
IMHO, I think there are two options.
- Accept Navigator key.
- Add API to RouteMaster which accept Route to handle Pageless Route( https://docs.google.com/document/d/1Q0jx0l4-xymph9O6zLaOY4d_f7YFpNWX_eGbzYxr9wY/edit#heading=h.ririyyxrggqr )so I can use navigate-without-a-context way. (This could be simple but needs to add all API in navigator.dart)
Thanks in advance. I love this library because of it’s simple API and declarative mapping from URL.
I think https://github.com/tomgilder/routemaster/pull/203 will solve this issue. Looking forward to being merged 😄
@tomgilder What's the reason behind this page assertion? Shouldn't any Route<T> implementer do? How else would one add a Dialog or BottomSheet as an overlay to the stack or as a named route save for the native solution as done by the author of this issue?
https://github.com/tomgilder/routemaster/blob/83a0d1a1d21c7d63ca65647862819a499de924d5/lib/routemaster.dart#L1423-L1428