refreshSyncStatus method

Future<void> refreshSyncStatus()

Refreshes the file synchronization status from the server.

Updates the local cache of file sync status to reflect the current state of pending uploads and sync progress.

Usage:

try {
  await communicator.refreshSyncStatus();
  print('File sync status refreshed');

  // Now get updated pending files info
  final pendingCount = await communicator.getPendingSyncCount();
  final pendingSize = await communicator.getPendingSyncSize();
} catch (e) {
  print('Failed to refresh sync status: $e');
}

Throws:

  • Future.error("Unable to refresh file sync status"): When refresh fails

Use Cases:

  • Updating sync progress indicators
  • Checking sync status before important operations
  • Refreshing UI displays of sync progress

Implementation

Future<void> refreshSyncStatus() async {
  try {
    await kruzr_comm.refreshSyncStatus();
  } on PlatformException catch (e, stackTrace) {
    if (kDebugMode) {
      print("Error in refreshSyncStatus");
      print(stackTrace);
      print(e);
    }
    return Future.error({"code": e.code, "message": e.message, "details": e.details});
  } on Exception catch (e, stackTrace) {
    if (kDebugMode) {
      print("Error in refreshSyncStatus");
      print(stackTrace);
      print(e);
    }
    return Future.error(PlatformException(code: "PLUGIN_ERROR", message: e.toString()));
  }
}