When I click on the notification in the foreground, I want to be redirected to another screen. How can I achieve that?
Answers (1)
Add AnswerFor Redirect to another screen when click on the notification when you are on foreground you have to implement this code.
In your main.dart screen you have to add this code.
await flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: selectNotification);
Here, one function called selectNotification. So you have to create that function on global declaration.
Future<void> selectNotification(payload) async { navigatorKey.currentState?.pushNamed('/settings-screen'); }
So, That’s how you can redirect to the another screen when click on notification in the foreground.