isAvailable property

bool get isAvailable

Whether the Flex delegate library is available.

Returns true if the library can be loaded, i.e., flutter_litert_flex is in the project's dependencies. Always false on Android, where flex was removed in flutter_litert 4.0.0.

Implementation

static bool get isAvailable {
  if (_isAndroid) return false;

  if (_flexLib != null) return true;

  // iOS: statically linked at build time by flutter_litert_flex podspec.
  if (Platform.isIOS) {
    try {
      DynamicLibrary.process().lookup<NativeFunction<Void Function()>>(
        'tflite_plugin_create_delegate',
      );
      return true;
    } catch (_) {
      return false;
    }
  }

  // Desktop: check app bundle paths (bundled by flutter_litert_flex).
  return _bundlePaths.any((p) => File(p).existsSync());
}