csells / go_router

The purpose of the go_router for Flutter is to use declarative routes to reduce complexity, regardless of the platform you're targeting (mobile, web, desktop), handling deep linking from Android, iOS and the web while still allowing an easy-to-use developer experience.
https://gorouter.dev
442 stars 96 forks source link

[documentation] how to use backbutton dispatcher #99

Closed aoatmon closed 2 years ago

aoatmon commented 2 years ago

Hello, maybe it's just me, but I cannot find any reference on if / how GoRouter provides a back button dispatcher

csells commented 2 years ago

It does not. Is that something you need it to do? What problem are you trying to solve?

FabianVarela commented 2 years ago

@aoatmon I made this implementation for BackButtonDispatcher and it works for me.

home: Router<dynamic>(
     routerDelegate: _router.routerDelegate,
     backButtonDispatcher: RootBackButtonDispatcher(),
),
csells commented 2 years ago

interesting. @FabianVarela @aoatmon what are you attempting to accomplish with the BackButtonDispatcher that GoRouter doesn't do by default?

mrseth01 commented 2 years ago

@csells I'm confused. You wrote that you need to provide a back button dispatcher. And then, you said Go Router does this by default.

How do I navigate back? I don't see a "goBack" or "pop" method on GoRouter? What is the best way to go back programmatically?

csells commented 2 years ago

Did I say that you needed to provide a BackButtonDispatcher? Can you point out where I said that so I can fix it?

Navigator.maybePop(context) will go back programmatically.