showSyncProgressNotification static method
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;
}
// Verificar se as notificações estão habilitadas
final areEnabled = await syncConfig.areNotificationsEnabled();
if (!areEnabled) {
SyncUtils.debugLog('Notificações não estão habilitadas', tag: 'BackgroundSyncService');
return;
}
if (indeterminate || (progress == null || maxProgress == null)) {
await syncConfig.showNotification(
title: title,
message: body,
notificationId: SyncConstants.progressNotificationId,
);
} else {
await syncConfig.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');
}
}