flutter / website

Flutter documentation web site
https://docs.flutter.dev
Other
2.8k stars 3.21k forks source link

Add caution about Router-based APIs compatibility with `WillPopScope` widget #9478

Open RamiroGarrido opened 1 year ago

RamiroGarrido commented 1 year ago

Page URL

https://docs.flutter.dev/ui/navigation/deep-linking#migrating-from-plugin-based-deep-linking

Page source

https://github.com/flutter/website/tree/main/src/cookbook/navigation/set-up-app-links.md

Describe the problem

You should specify on the web page that the suggested package go_router has NO compatibility with the WillPopScope widget (https://api.flutter.dev/flutter/widgets/WillPopScope-class.html) as stated on the go_router official library page (read the Prevent navigation subtitle) : https://pub.dev/documentation/go_router/latest/topics/Navigation-topic.html

I believe this should be mandatory to mention because the WillPopScope is used to prevent unwanted navigations with the native back buttons on Android (and iOS as I understand), making this widget a must on many mobile projects using flutter.

The mentioned incompatibility prevents any migrations to the suggested package from projects already using the WillPopScope widget.

Please alert people about this incompatibility and stop suggesting a migration to the go_router package, because it doesn't support all possible scenarios necessary for mobile development (as I understand the bug with the WillPopScope is still an open issue: https://github.com/flutter/flutter/issues/102408 )....

It'd be nice to have a warning, so people don't attempt a migration that's not going to work with their current code or their use cases.

Thank u!

Expected fix

A text alerting people about the incompatibility with the WillPopScope widget would be nice. Sharing the link to the open issue about this would be great as well: https://github.com/flutter/flutter/issues/102408

Additional context

No response

danagbemava-nc commented 1 year ago

Hi @RamiroGarrido, are you proposing that this notice be added to the cookbook or the deeplink page or both?

RamiroGarrido commented 1 year ago

Hi @RamiroGarrido, are you proposing that this notice be added to the cookbook or the deeplink page or both?

Both would be nice...I think it's better to have two warnings than only one, in case someone misses the first one...

pchasco commented 8 months ago

I think we should go further in the warning. If a WillPopScope widget is in the widget tree while using GoRouter, a warning should be displayed in the console. Hopefully that could help to disuade people from wasting as many hours as I have trying to migrate to GoRouter only to find out that it is still only half-baked.