getPendingSyncSize method
Retrieves the total size of files pending synchronization.
Returns the total size in bytes of trip data files waiting to be uploaded to Kruzr servers.
Returns:
num?: Total size in bytes of pending files, ornullif unavailable
Usage:
try {
final pendingSize = await communicator.getPendingSyncSize();
if (pendingSize != null && pendingSize > 0) {
final sizeInMB = pendingSize / (1024 * 1024);
print('${sizeInMB.toStringAsFixed(2)} MB pending upload');
}
} catch (e) {
print('Failed to get pending files size: $e');
}
Throws:
Future.error("Unable to get files size"): When retrieval fails
Use Cases:
- Estimating sync time and data usage
- Showing storage space information
- Determining sync priority based on data size
Implementation
Future<num?> getPendingSyncSize() async {
try {
return await kruzr_comm.getPendingFilesSize();
} on PlatformException catch (e, stackTrace) {
if (kDebugMode) {
print("Error in getPendingSyncSize");
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 getPendingSyncSize");
print(stackTrace);
print(e);
}
return Future.error(PlatformException(code: "PLUGIN_ERROR", message: e.toString()));
}
}