setAppBadge method

Future<void> setAppBadge(
  1. int count
)

Refreshes the current browser's page.

Implementation

Future<void> setAppBadge(int count) async {
  Log.debug('setAppBadge($count)', '$runtimeType');

  if (isWeb) {
    return WebUtils.setBadge(count);
  }

  if (isWindows) {
    try {
      if (count == 0) {
        await WindowsTaskbar.resetOverlayIcon();
      } else {
        final String number = count > 9 ? '9+' : '$count';
        await WindowsTaskbar.setOverlayIcon(
          ThumbnailToolbarAssetIcon('assets/icons/notification/$number.ico'),
        );
      }
    } catch (_) {
      // No-op.
    }
  }

  try {
    if (await FlutterNativeBadge.isSupported()) {
      if (count == 0) {
        await FlutterNativeBadge.clearBadgeCount();
      } else {
        await FlutterNativeBadge.setBadgeCount(count);
      }
    }
  } catch (_) {
    // No-op.
  }
}