Skip to content
pubscout

dart_eval

0.8.5, released 6 months ago by ethanblake.xyz

A flexible Dart bytecode compiler and interpreter for dynamic execution and code push.

$ flutter pub add dart_eval
Source repository

What it does

Compiles and interprets Dart bytecode at runtime, allowing dynamic code execution and hot updating (code push) for AOT-compiled Dart and Flutter apps. It includes automated interop and binding generation systems so native Dart code can be used inside the interpreter and vice versa.

AI-written summary of version 0.8.5, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need code push capabilities for Flutter AOT apps.
  • You want to execute arbitrary or user-submitted Dart code safely via a sandbox with granular permissions.

Skip it when

  • You require 100% of the standard library and all advanced language features immediately supported out of the box.
  • Maximum execution performance is critical, as interpreted bytecode is slower than native AOT/JIT execution.

Strengths

  • Enables code push and dynamic execution in AOT Flutter apps.
  • Automated interop and binding generator for seamlessly using native classes in the interpreter.
  • Built-in sandboxing and permission system for secure execution.

Weaknesses

  • Does not yet implement certain language features (e.g., generators, extension methods) and parts of the standard library.
  • Runtime performance of interpreted code is lower than native execution.

Setup

Kind
Pure Dart
Effort
Medium
Code generation
Yes (build_runner)
Direct dependencies
13

Add dart_eval to dependencies, optionally use the CLI for pre-compiling EVC bytecode or generating interop bindings via eval_annotation.

import 'package:dart_eval/dart_eval.dart';

void main() {
  print(eval('2 + 2')); // -> 4
}

Alternatives

Packages that do the same job and could replace dart_eval.

  • shorebird_code_push

    If you need full native binary updates via a hosted code push service rather than bytecode interpretation.

Works with

Packages commonly used together with dart_eval: ones it builds on, ones built on it, and its own family.