VmServiceRuntime class

The default FlutterRuntime backed by package:vm_service. Owns one VmClient and centralises every ext.flutter.inspector.* and evaluate call site.

Implemented types

Constructors

VmServiceRuntime({VmClient? client})

Properties

attachedUri → Uri?
The URI we're attached to, when known.
no setteroverride
extensionEvents → Stream<Event>
Events apps post with postEvent, such as the agent's lifecycle changes.
no setter
flutterIsolateId → String
Raw selected Flutter isolate id. Same caveat as rawService.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
isAttached → bool
Currently attached to a VM service.
no setteroverride
isolateExits → Stream<String>
Ids of isolates that exit; empty while the client is not connected.
no setter
loggingEvents → Stream<Event>
Broadcast stream of LoggingEvents from developer.log and package:logging consumers.
no setteroverride
onDisconnect → Stream<void>
Fires once when the VM service WebSocket closes (hot restart, app kill, etc.). Use this to trigger auto-reconnect. Implementors broadcast one event then close the stream.
no setteroverride
rawService → VmService
Raw VM service handle. Try not to use this from glint code — the whole point of FlutterRuntime is to keep this surface contained to one adapter. Exposed for verify scripts and adapter authors.
no setteroverride
rootLibraryUri → String?
Root library URI of the Flutter isolate, e.g. package:acme_pay/main.dart. The package segment is the app's pubspec name — the surest "which app".
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectedIsolateId → String?
The Flutter isolate's id, or null before one is selected.
no setter
stderrEvents → Stream<Event>
Broadcast stream of WriteEvents from the Flutter app's stderr.
no setteroverride
stdoutEvents → Stream<Event>
Broadcast stream of WriteEvents from the Flutter app's stdout. FlutterError dumps land here (not stderr — debugPrint → print → stdout), so error-capture pipelines must subscribe.
no setteroverride

Methods

appRootDirectory() → Future<String?>
The app's package root (…/app, no /lib), from the resolved main library; null when it cannot be resolved.
override
attach(Uri vmServiceUri) → Future<void>
Attach to a VM service over its WebSocket URI. Selects the first isolate exposing ext.flutter.* extensions and listens to the stderr / stdout / logging event streams. Subsequent calls re-attach.
override
callExtensionOrNull(String method, Map<String, String> args, {Duration? timeout}) → Future<Map<String, Object?>?>
Calls service extension method in the Flutter isolate; null when the isolate has not registered it.
disconnect() → Future<void>
Best-effort disconnect; safe to call multiple times.
override
disposeInspectorGroup(String groupName) → Future<void>
Best-effort cleanup of the inspector's object-group id table. Never throws — callers don't need to wrap this.
override
evaluate(String expression) → Future<InstanceRef>
Evaluates expression in a library with the Flutter widgets API in scope (framework first, then the app's own). Returns the raw InstanceRef for the caller to crack open by type. Throws RuntimeEvalError on compilation error or ErrorRef return.
override
evaluateIn(String expression, {String? librarySuffix, Map<String, String>? scope}) → Future<InstanceRef>
Evaluates expression in the loaded library whose uri ends with librarySuffix (the usual eval library when null), with scope naming live object ids.
override
evaluateString(String expression, {bool rethrowErrors = false}) → Future<String?>
Evaluates expression and returns its valueAsString, transparently refetching via getObject when the value is truncated past the 128-char preview. Returns null for a non-string result, and for an eval error unless rethrowErrors, which rethrows the RuntimeEvalError.
override
evaluateStringIn(String expression, {required String librarySuffix}) → Future<String?>
evaluateString in the library whose uri ends with librarySuffix, for private state such as the timer heap of dart:isolate.
evaluateWithSelection({required String expression, required String inspectorId, required String groupName}) → Future<String?>
Sets the inspector selection to inspectorId in groupName, then evaluates expression against the root library. Returns null on any eval failure. Shorthand for the enricher pattern setInspectorSelection → evaluateString.
override
isolateReady() → Future<void>
Resolves once any re-selection of the Flutter isolate (after a hot restart) has finished.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
readDetailsSubtree({required String inspectorId, required String groupName, int subtreeDepth = 5}) → Future<InspectorJson>
Returns the subtree rooted at inspectorId including each node's DiagnosticsProperty values. Used for selective per-node detail reads (input field values, icon codepoints, etc.).
override
readWidgetTree({required String groupName, bool isSummaryTree = true, bool withPreviews = true, bool fullDetails = false}) → Future<InspectorJson>
Returns the inspector's widget tree as raw DiagnosticsNode JSON. isSummaryTree: true (the default) filters out framework internals; false returns the full element tree.
override
setInspectorSelection({required String inspectorId, required String groupName}) → Future<void>
Sets WidgetInspectorService.instance.selection to inspectorId so a subsequent evaluate has selection.currentElement available.
override
setPubRootDirectories(List<String> dirs) → Future<void>
Registers dirs as pub roots so the inspector marks the app's own widgets as local-project and keeps them in the summary tree.
override
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

withCallLimit<T>(Duration? limit, Future<T> body(), {Duration evaluateLimit()?}) → Future<T>
Runs body with every cheap VM call held to limit and every expression evaluate held to evaluateLimit (10 s when null, since compiling is legitimate); null limit lifts an outer one, and a tree read gets twice as long.

Constants

callTimeout → const Duration
Wraps a VM service call and converts disconnect-class errors to RuntimeConnectionLostError so the tool layer can return a structured, recoverable GlintErrorKind.connectionLost response. Longest a single VM service call may take before it is reported as RuntimeUnresponsiveError.
disposeTimeout → const Duration
Cleanup is not worth blocking a reply on: a suspended app (device locked) never answers.
frameworkEvalLibraries → const List<String>
Framework libraries whose imports cover every glint expression; tried before the app's own so an app entry that never imports Flutter still works.
scopeCanary → const String
Compiles only where every Flutter name glint's expressions use is in scope.
treeWarmupLimit → const Duration
How long after glint first reads an isolate its tree may be missing, as right after a hot restart or before the first frame.