call method

Future<Map<String, Object?>> call(
  1. Map<String, String> args, {
  2. Duration? timeout,
  3. bool dropLate = false,
})

Calls the agent with args, installing it first in a fresh isolate (after attach or a hot restart); with dropLate the app skips the call if it only runs after timeout, so input glint gave up on never lands later.

Implementation

Future<Map<String, Object?>> call(Map<String, String> args, {Duration? timeout, bool dropLate = false}) async {
  for (var attempt = 0; attempt < 2; attempt++) {
    if (_installedIn != runtime.flutterIsolateId) await _install();
    final offset = _clockOffsetMs;
    final sent = dropLate && timeout != null && offset != null
        ? {...args, 'expires': '${DateTime.now().millisecondsSinceEpoch + offset + timeout.inMilliseconds}'}
        : args;
    final reply = await runtime.callExtensionOrNull(kAgentExtension, sent, timeout: timeout);
    if (reply != null) return reply;
    _installedIn = null;
  }
  throw RuntimeEvalError(kAgentExtension, 'the in-app agent did not register');
}