callbackDispatcher function

void callbackDispatcher()

Callback dispatcher para o WorkManager

Implementation

@pragma('vm:entry-point')
void callbackDispatcher() {
  Workmanager().executeTask((task, inputData) async {
    SyncUtils.debugLog('Executando tarefa em background: $task', tag: 'BackgroundSyncService');

    switch (task) {
      case 'background_sync_task':
      case 'immediate_sync':
        try {
          await _performBackgroundSync();
          SyncUtils.debugLog('Sincronização em background concluída com sucesso', tag: 'BackgroundSyncService');
          return Future.value(true);
        } catch (e) {
          SyncUtils.debugLog('Erro na sincronização em background: $e', tag: 'BackgroundSyncService');
          return Future.value(false);
        }
      default:
        SyncUtils.debugLog('Tarefa desconhecida: $task', tag: 'BackgroundSyncService');
        return Future.value(false);
    }
  });
}