eval method

Future<InstanceRef?> eval(
  1. String expression, {
  2. required Disposable? isAlive,
  3. Map<String, String>? scope,
  4. bool shouldLogError = true,
})

Implementation

Future<InstanceRef?> eval(
  String expression, {
  required Disposable? isAlive,
  Map<String, String>? scope,
  bool shouldLogError = true,
}) async {
  if ((scope?.isNotEmpty ?? false) &&
      serviceManager.connectedApp!.isDartWebAppNow!) {
    final result = await eval(
      '(${scope!.keys.join(',')}) => $expression',
      isAlive: isAlive,
      shouldLogError: shouldLogError,
    );
    if (result == null || (isAlive?.disposed ?? true)) return null;
    return await invoke(
      result,
      'call',
      scope.values.toList(),
      isAlive: isAlive,
      shouldLogError: shouldLogError,
    );
  }
  return await addRequest<InstanceRef?>(
    isAlive,
    () => _eval(
      expression,
      scope: scope,
      shouldLogError: shouldLogError,
    ),
  );
}