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 fromdeveloper.logandpackage:loggingconsumers.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
methodin 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
expressionin a library with the Flutter widgets API in scope (framework first, then the app's own). Returns the rawInstanceReffor 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
expressionin the loaded library whose uri ends withlibrarySuffix(the usual eval library when null), withscopenaming live object ids.override -
evaluateString(
String expression, {bool rethrowErrors = false}) → Future< String?> -
Evaluates
expressionand returns itsvalueAsString, transparently refetching viagetObjectwhen the value is truncated past the 128-char preview. Returns null for a non-string result, and for an eval error unlessrethrowErrors, 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 ofdart:isolate. -
evaluateWithSelection(
{required String expression, required String inspectorId, required String groupName}) → Future< String?> -
Sets the inspector selection to
inspectorIdingroupName, then evaluatesexpressionagainst the root library. Returns null on any eval failure. Shorthand for the enricher patternsetInspectorSelection→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
inspectorIdincluding 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;falsereturns the full element tree.override -
setInspectorSelection(
{required String inspectorId, required String groupName}) → Future< void> -
Sets
WidgetInspectorService.instance.selectiontoinspectorIdso a subsequent evaluate hasselection.currentElementavailable.override -
setPubRootDirectories(
List< String> dirs) → Future<void> -
Registers
dirsas 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
bodywith every cheap VM call held tolimitand every expression evaluate held toevaluateLimit(10 s when null, since compiling is legitimate); nulllimitlifts 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.