getPendingSyncCount method
Retrieves the number of files pending synchronization.
Returns the count of trip data files that are waiting to be uploaded to Kruzr servers.
Returns:
num?: Number of pending files, ornullif unavailable
Usage:
try {
final pendingCount = await communicator.getPendingSyncCount();
if (pendingCount != null && pendingCount > 0) {
print('$pendingCount files pending upload');
// Show sync progress indicator
} else {
print('All files synchronized');
}
} catch (e) {
print('Failed to get pending files count: $e');
}
Throws:
Future.error("Unable to get files count"): When retrieval fails
Use Cases:
- Displaying sync progress to users
- Determining if sync is needed
- Progress bar calculations
Implementation
Future<num?> getPendingSyncCount() async {
try {
return await kruzr_comm.getPendingFilesCount();
} on PlatformException catch (e, stackTrace) {
if (kDebugMode) {
print("Error in getPendingSyncCount");
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 getPendingSyncCount");
print(stackTrace);
print(e);
}
return Future.error(PlatformException(code: "PLUGIN_ERROR", message: e.toString()));
}
}