VmServiceClient class

Wrapper around package:vm_service exposing the fluttersdk-house-style surface that artisan connected-mode commands consume.

Critical design choice: getMainIsolateId() calls getVM on EVERY invocation (NO closure caching). The ai-test MCP server's prior implementation cached the isolate id at first lookup and broke on device-target switches when the underlying app restarted on a different isolate. The fix was to drop the cache; this wrapper inherits that correctness over speed trade-off (sub-ms cost on local WebSocket).

DDS namespace mapping is handled transparently by package:vm_service when the WebSocket URI points at a DDS endpoint (which flutter run does by default).

Constructors

VmServiceClient(String wsUri)

Properties

hashCode int
The hash code for this object.
no setterinherited
isConnected bool
no setter
lastResolvedIsolateId String?
Reports the last isolate id this client transparently refreshed away from. Callers that cache the isolate id can listen on onIsolateRefreshed and update their cache without reaching into getMainIsolateId after every tool call.
no setter
onIsolateEvent Stream<Event>
Stream of isolate-level events (used by tinker autocomplete to invalidate its cached corpus on kIsolateReload).
no setter
onIsolateRefreshed Stream<String>
Broadcasts whenever the retry path inside callServiceExtension recovers from a stale-isolate sentinel by reaching for a fresh id. Single subscriber per cache (mcp_server uses one); broadcast so multiple commands can listen without contention.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
wsUri String
final

Methods

callServiceExtension<T>(String method, {required String isolateId, Map<String, dynamic>? params}) Future<T>
Call a VM Service extension method (delegates to vm.callServiceExtension which is DDS-namespace transparent).
connect() Future<void>
disconnect() Future<void>
evaluate(String isolateId, String expression) Future<Response>
Evaluate a Dart expression in the running app's root library. Wraps the expression in (() async => $expr)() when it contains await so the caller doesn't need to think about await-awareness.
getExtensionRPCs(String isolateId) Future<List<String>>
Returns the list of ext.* extension RPCs registered on the isolate. Used by fluttersdk_mcp for runtime tool discovery.
getMainIsolateId() Future<String>
Fresh isolate-id lookup on every call (no cache). See class doc.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reloadSources(String isolateId, {bool force = false}) Future<ReloadReport>
Hot reload — incremental Dart source re-import without losing isolate state. Equivalent to pressing r in flutter run. Caller invokes ext.flutter.reassemble afterwards to rebuild the widget tree.
streamListen(String streamId) Future<void>
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited