showSyncProgressNotification static method

Future<void> showSyncProgressNotification({
  1. required String title,
  2. required String body,
  3. int? progress,
  4. int? maxProgress,
  5. bool indeterminate = false,
})

Exibe uma notificação de progresso da sincronização

Implementation

static Future<void> showSyncProgressNotification({
  required String title,
  required String body,
  int? progress,
  int? maxProgress,
  bool indeterminate = false,
}) async {
  try {
    final syncConfig = _getSyncConfig();
    if (syncConfig == null || !syncConfig.enableNotifications) {
      return;
    }

    if (indeterminate || (progress == null || maxProgress == null)) {
      await SyncNotificationService.instance.showNotification(
        title: title,
        message: body,
        notificationId: SyncConstants.progressNotificationId,
      );
    } else {
      await SyncNotificationService.instance.showProgressNotification(
        title: title,
        message: body,
        progress: progress,
        maxProgress: maxProgress,
        notificationId: SyncConstants.progressNotificationId,
      );
    }
  } catch (e) {
    SyncUtils.debugLog('Erro ao exibir notificação de progresso: $e', tag: 'BackgroundSyncService');
  }
}