require<T> static method

Future<T> require<T>(
  1. String method, [
  2. Object? arguments
])

Implementation

static Future<T> require<T>(String method, [Object? arguments]) async {
  final handler = _handlers[method];
  if (handler == null) {
    throw StateError(
      'Native binding "$method" is not registered. Generate and register an FFI/ffigen or JNI/jnigen binding before calling this API.',
    );
  }
  final value = await handler(arguments);
  if (value is! T) {
    throw StateError(
      'Native binding "$method" returned ${value.runtimeType}, expected $T.',
    );
  }
  return value;
}