routemaster icon indicating copy to clipboard operation
routemaster copied to clipboard

What is the best way to use Pageless route without context?

Open haradakunihiko opened this issue 3 years ago • 2 comments

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.

  1. Accept Navigator key.
  2. 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.

haradakunihiko avatar Oct 06 '21 04:10 haradakunihiko

I think https://github.com/tomgilder/routemaster/pull/203 will solve this issue. Looking forward to being merged 😄

haradakunihiko avatar Oct 07 '21 01:10 haradakunihiko

@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

noga-dev avatar Nov 07 '21 02:11 noga-dev