2

I am using the Flutter notification_permissions package.

I can retrieve the device notification permission status asynchronously by calling:

PermissionStatus p = await NotificationPermissions.getNotificationPermissionStatus()

However, I do not want to do this just once. I want to listen to the notification status as a stream, so that when it changes I can respond accordingly in my UI.

I tried the following:

NotificationPermissions.getNotificationPermissionStatus().asStream().listen((PermissionStatus s) {
    print('Notification permissions: $s');   
}

However, this stream does not emit events when I change the notification settings on the device.

How can I achieve this?

Ollie
  • 624
  • 8
  • 27

1 Answers1

3

I have achieved my desired functionality by creating a stateful widget that listens to the AppLifecycleState. I then call my async function whenever the app resumes to check the status of notification settings.

More info here: Flutter: Update Widgets On Resume?

Ollie
  • 624
  • 8
  • 27