getChannels method

Future<List<AndroidNotificationChannel>> getChannels()

Gets all created notification channels.

Returns a list of channels that have been created on the device. Returns empty list on iOS and web.

Implementation

Future<List<AndroidNotificationChannel>> getChannels() async {
  if (kIsWeb || !Platform.isAndroid) {
    return [];
  }

  try {
    final androidPlugin =
        _plugin.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>();

    if (androidPlugin == null) {
      return [];
    }

    final channels = await androidPlugin.getNotificationChannels();
    return channels ?? [];
  } catch (e, stack) {
    loge(stack, 'Failed to get notification channels: $e');
    return [];
  }
}