invokeCommand method
Invokes a command by stable ID, pumping requested frames while it waits. Test time does not advance automatically. For a command that awaits a dialog, start the invocation, answer the dialog, then await its result.
Resolution follows app-shell expectations: nearest local command scopes win first, then active screen commands, then app/parent commands.
Implementation
Future<CommandInvocationResult> invokeCommand(
CommandId id, {
BuildContext? context,
}) async {
_assertNotDisposed('invokeCommand');
final buildContext = _defaultCommandContext(context);
final registry = commandRegistry(context: buildContext);
final resolution = _resolveCommandForTester(id, registry, buildContext);
final result = await _runAction(
() => resolution == null
? registry.invoke(id, buildContext: buildContext)
: resolution.registry.invokeCommand(
resolution.command,
buildContext: buildContext,
),
);
_owner.flushBuild();
return result;
}