checkStorageAvailable static method
Check if storage is available for a model download
Returns true if sufficient storage is available for the given model size.
Implementation
static Future<bool> checkStorageAvailable({
required int modelSize,
double safetyMargin = 0.1,
}) async {
try {
final directory = await getApplicationDocumentsDirectory();
final requiredWithMargin = (modelSize * (1 + safetyMargin)).toInt();
// Get directory size as a proxy for available space check
final dirSize = await _getDirectorySize(directory);
// If the SDK directory is larger than the model size,
// we assume storage is available (simplified check)
return dirSize > requiredWithMargin;
} catch (_) {
// Default to available if check fails
return true;
}
}