evaluate method
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.
Implementation
Future<vm.Response> evaluate(String isolateId, String expression) async {
final s = _requireConnected();
final iso = await s.getIsolate(isolateId);
final rootLibId = iso.rootLib?.id;
if (rootLibId == null) {
throw StateError('Isolate has no root library; cannot evaluate.');
}
final wrapped = expression.contains('await')
? '(() async => $expression)()'
: expression;
return await s.evaluate(isolateId, rootLibId, wrapped);
}