dart_eval library

A library providing a Dart bytecode compiler and interpreter.

Classes

Compiler
Compiles Dart source code into EVC bytecode, outputting a Program.
Program
A Program is a compiled EVC bytecode program that can be executed using a Runtime.
Runtime
A Runtime is a virtual machine instance that executes EVC bytecode.

Properties

globalRuntime Runtime?
The global runtime instance to be used for overrides
getter/setter pair
runtimeOverrides Map<String, OverrideSpec>?
Mapping of runtime overrides, which can be used to dynamically swap implementations of functions at runtime by a unique ID
getter/setter pair
runtimeOverrideVersion Version?
The current semver Version of your app. Overriden functions can specify a version constraint in their @RuntimeOverride annotation which will be checked against this version to determine if the override should apply.
getter/setter pair

Functions

eval(String source, {String function = 'main', List args = const [], List<EvalPlugin> plugins = const [], List<Permission> permissions = const [], String? outputFile}) → dynamic
Evaluate the Dart source code. If the source is a raw expression such as "2 + 2" it will be evaluated directly and the result will be returned; otherwise, the function function will be called with arguments specified by args. You can use plugins to configure bridge classes and permissions to grant permissions to the runtime. You can also specify outputFile to write the generated EVC bytecode to a file.