unload static method
Unload whatever is loaded under category. No-op when nothing is.
Throws SDKException when the unload fails.
Implementation
static Future<void> unload(ModelCategory category) async {
if (!DartBridge.isInitialized) {
throw SDKException.notInitialized();
}
final current = await RunAnywhereModelLifecycle.shared.current(
model_pb.CurrentModelRequest(category: category),
);
if (!current.found || current.modelId.isEmpty) {
return;
}
final result = await RunAnywhereModelLifecycle.shared.unload(
model_pb.ModelUnloadRequest(
modelId: current.modelId,
category: category,
),
);
if (result.hasError()) {
throw SDKException.invalidState(
result.error.message.isNotEmpty
? result.error.message
: 'Model lifecycle unload failed',
);
}
}