checkModelExists static method

Future<Map<String, dynamic>> checkModelExists(
  1. String modelPath
)

Checks if a model exists at the specified path.

This method can check for models in assets, internal storage, or at an absolute path.

modelPath The path to check returns A map containing information about the model existence and location

Implementation

static Future<Map<String, dynamic>> checkModelExists(String modelPath) async {
  try {
    final channel = ChannelConfig.createSingleImageChannel();
    final result = await channel.invokeMethod('checkModelExists', {
      'modelPath': modelPath,
    });

    if (result is Map) {
      return Map<String, dynamic>.fromEntries(
        result.entries.map((e) => MapEntry(e.key.toString(), e.value)),
      );
    }

    return {'exists': false, 'path': modelPath, 'location': 'unknown'};
  } catch (e) {
    String errorMessage = e.toString();
    if (e is PlatformException && e.message != null) {
      errorMessage = e.message!;
    }
    return {'exists': false, 'path': modelPath, 'error': errorMessage};
  }
}