When I click on the notification in the foreground, I want to be redirected to another screen. How can I achieve that?

Forums FlutterWhen I click on the notification in the foreground, I want to be redirected to another screen. How can I achieve that?
Staff asked 2 months ago

Answers (1)

Add Answer
Darshit Rudani Marked As Accepted
Staff answered 2 months ago

For 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.

Subscribe

Select Categories