syncTripData method

Future<void> syncTripData()

Synchronizes local trip data with Kruzr servers.

Uploads any pending trip data that hasn't been synchronized yet, ensuring all trip information is safely stored in the cloud.

Usage:

try {
  await communicator.syncTripData();
  print('Trip data synchronized successfully');
} catch (e) {
  print('Failed to sync trip data: $e');
}

Throws:

  • Future.error("Unable to sync trip data"): When synchronization fails

Important Notes:

  • Requires internet connection
  • May take time for large amounts of data
  • Should be called periodically or after trip completion
  • Respects WiFi-only sync preferences if configured

Implementation

Future<void> syncTripData() async {
  try {
    await kruzr_comm.syncTripData();
  } on Exception catch (e, stackTrace) {
    if (kDebugMode) {
      print("Error in syncTripData");
      print(stackTrace);
      print(e);
    }
    return Future.error("Unable to sync trip data");
  }
}