clearModelFiles static method

Future<void> clearModelFiles(
  1. ModelSpec spec
)

Removes all files of a model specification from SharedPreferences

Implementation

static Future<void> clearModelFiles(ModelSpec spec) async {
  try {
    final prefs = await _prefs;

    final operations = <Future<bool>>[];

    for (final file in spec.files) {
      operations.add(prefs.remove(file.prefsKey));
    }

    await Future.wait(operations);
    debugPrint('Cleared model files from SharedPreferences: ${spec.name}');
  } catch (e) {
    debugPrint('Failed to clear model files for ${spec.name}: $e');
    throw ModelStorageException(
      'Failed to clear model files from SharedPreferences',
      e,
      'clear_prefs',
    );
  }
}