Search code examples
flutterdeep-linkingflutter-go-router

When using the go_router package in Flutter, is it possible to use the "extra" parameter to pass some data and have it worked with deep-linking?


I saw in the old documentation that using the "extra" parameter to pass data to another page was not working with deep-linking.

I cannot see that in the current documentation (look at the "Using extra" section at the bottom of the page).

Has it been modified and can "extra" parameters be used with deep-linking now?

I did not try both implementations to see which are working. I'm preemptively asking this question to have some clues before tackling this work.


Solution

  • The extra object is passed outside of the current route. There is no way for your app to know what the object is when visiting the destination via deep linking.

    If you visit go_router_builder documentation, in the Extra parameter section, they do mention:

    The $extra parameter is still passed outside the location, still defeats dynamic and deep linking (including the browser back button) and is still not recommended when targeting Flutter web.

    If you want your app to support deep linking, you should not rely on the extra parameter. Instead, pass an identifier to the route

    /things/:id

    and it is now the responsibility of that route to figure out how to get the data with the id, rather than getting it from the extra parameter.