Natural selection is testing this #Altcoins season 🌊. In this cycle, many are once again diving deep into research, searching for “the best” after Bitcoin & @Joseinnewworld makes waves 124 #NFTs — Wow, a strong signal for those still weighing their moves. #eCash $XEC #CryptoNews pic.twitter.com/GB3dRvH01U
— NFToa (@nftoa_) September 26, 2025
I encountered this unique case when trying to navigate a push notification from the main page to a related page. However, it seemed that the context in main.dart was not compatible, as if the navigator was never executed.
Solution
I eventually used thedidChangeAppLifecycleState method, which does not provide any context, unlike the build method. You need to navigate without using context by setting a global key for your navigation:final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
Setting the navigatorKey in MaterialApp
MaterialApp(
title: 'MyApp',
onGenerateRoute: generateRoute,
navigatorKey: navigatorKey,
);
Execute navigation like this:
navigatorKey.currentState.pushNamed('/someRoute');
Done!
