state method

Future<ModelsState> state()

What is loaded and how much storage the SDK occupies.

Throws SDKException when the SDK is not initialized.

Implementation

Future<ModelsState> state() async {
  if (!DartBridge.isInitialized) {
    throw SDKException.notInitialized();
  }
  final loaded = <ModelCategory, ModelInfo>{};
  for (final category in _loadableCategories) {
    final id = await ModelGate.currentId(category);
    if (id == null) continue;
    final model = await get(id);
    if (model != null) loaded[category] = model;
  }
  final storage = await RunAnywhereDownloads.shared.getStorageInfo();
  return ModelsState.fromProto(loaded, storage);
}