How do I refresh the current route when arguments change?

Issue

I’m using auto_route with some arguments as url parameters. If I push the same route as the one I’m currently on, but using different parameters, then the displayed widget is not updated.

Why not? Can I force it to update or is there a setting for auto_route to detect these changes?

Solution

By default auto_route treats route name as its key. You can change that behavior with the usePathAsKey argument in the *Route class:

Property Default value Definition
usePathAsKey false if true path is used as page key instead of name

source

Answered By – Albert221

Answer Checked By – David Marino (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *