title: to enable or disable the notification flutter
body: <p>I want to enable/disable the notification service with help of a button when this button is enabled, the user receives the notification, and when it's disabled he won't receive any notifications.</p>
  
  <pre><code>import 'dart:io';
  
  import 'package:firebase_messaging/firebase_messaging.dart';
  
  class FirebaseNotifications {
    FirebaseMessaging _firebaseMessaging;
  
    void setUpFirebase() {
      _firebaseMessaging = FirebaseMessaging();
      firebaseCloudMessaging_Listeners();
  
    }
  
    void firebaseCloudMessaging_Listeners() {
      if (Platform.isIOS) iOS_Permission();
  
      _firebaseMessaging.getToken().then((token) {
        print(token);
      });
  
      _firebaseMessaging.configure(
        onMessage: (Map&lt;String, dynamic&gt; message) async {
          print('on message $message');
        },
        onResume: (Map&lt;String, dynamic&gt; message) async {
          print('on resume $message');
        },
        onLaunch: (Map&lt;String, dynamic&gt; message) async {
          print('on launch $message');
        },
      );
    }
  
    void iOS_Permission() {
      _firebaseMessaging.requestNotificationPermissions(
          IosNotificationSettings(sound: true, badge: true, alert: true));
      _firebaseMessaging.onIosSettingsRegistered
          .listen((IosNotificationSettings settings) {
        print("Settings registered: $settings");
      });
    }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/70U4g.jpg" rel="noreferrer">enter image description here</a></p>