Scorb
Scorb

Reputation: 1920

Is there a down side to using GlobalKey<NavigatorState> to do all my route navigation?

I have seen an example in flutter where you can navigate routes without having access to a BuildContext.

final GlobalKey<NavigatorState> _navKey = new GlobalKey<NavigatorState>();

navigatorKey.currentState.pushNamed('/');

Are there any drawbacks to doing all of my apps navigation with this method?

Upvotes: 7

Views: 1087

Answers (1)

Scorb
Scorb

Reputation: 1920

No. There is no downside.

The performance concern is negligible in regards to screen switches.

Upvotes: 1

Related Questions