nubank / nuvigator

A powerful routing abstraction over Flutter Navigator, with nested Navigator and Deeplinks
Apache License 2.0
277 stars 33 forks source link

Allow deepLinks as the initialRoute #22

Closed rafaelring closed 4 years ago

rafaelring commented 4 years ago

In some scenarios we'd want to use deep links as the initial route - let's say we're opening a flutter screen from a native screen and want to directly enter a screen, the canonical way to do this with flutter is to set the initialRoute property on the native side and so Material's Navigation will know that it needs to open some other path as route. The problem is that in this scenario we shouldn't expect the native screen to know the name of nuvigator's route and thus, using a deep link seems like a more abstract way to do this. This commit adds support to set a deep link as the initialRoute value however, to do this we needed to change the deeplink resolution function (getRouteEntryForDeepLink) to be synchronous instead of asynchronous. The reason it was async before was that the function to get the deepLink prefix (deepLinkPrefix) was async as a hook for a case in which someone needed to set this asynchronously. However, we feel that while it's a breaking change, it's more valueable to support deep links as the initial route than the capability of getting the prefix asynchronously.