FlutterLocalNotificationsPlugin.private constructor Null safety

  1. @visibleForTesting
FlutterLocalNotificationsPlugin.private(
  1. Platform platform
)

Used internally for creating the appropriate platform-specific implementation of the plugin.

This can be used for tests as well. For example, the following code

FlutterLocalNotificationsPlugin.private(FakePlatform(operatingSystem:
'android'))

could be used in a test needs the plugin to use Android implementation

Implementation

@visibleForTesting
FlutterLocalNotificationsPlugin.private(Platform platform)
    : _platform = platform {
  if (platform.isAndroid) {
    FlutterLocalNotificationsPlatform.instance =
        AndroidFlutterLocalNotificationsPlugin();
  } else if (platform.isIOS) {
    FlutterLocalNotificationsPlatform.instance =
        IOSFlutterLocalNotificationsPlugin();
  } else if (platform.isMacOS) {
    FlutterLocalNotificationsPlatform.instance =
        MacOSFlutterLocalNotificationsPlugin();
  }
}