dart_repl 0.11.1

  • README.md
  • Installing
  • Versions
  • 43



A proof of concept REPL environment for Dart.

asciicast asciicast

See the Dart REPL Directions brain-dump for possible ideas and directions.


pub global run

You can install and setup dart_repl using:

pub global activate dart_repl

To run it, simply execute:

pub global run dart_repl

If you run it from a directory that contains a Dart package (it needs a .packages file), it will load all dependencies automatically and allow you to import libraries adhoc from the command-line:

pub global run dart_repl --adhoc-import package:built_collection/built_collection.dart

(if your package depends on built_collection).

Alternatively, you can use the import() builtin command instead of the commmand-line flag --adhoc-import:

$ pub global run dart_repl

>>> import('package:built_collection/built_collection.dart');

This is the preferred way of running dart_repl as it requires no additional setup.

From another package

You can add a dev_dependency: to your pubspec.yaml:


You can then run the REPL with:

pub run dart_repl

It will automatically resolve all additional adhoc imports against the dependencies of your package:

pub run dart_repl --adhoc-import package:built_collection/built_collection.dart

From a checkout

From the command-line

dart bin/dart_repl.dart

To import additional libraries, you need to specify a package directory (--package-dir) to allow it to resolve dependencies:

dart bin/dart_repl.dart --package-dir ~/git/built_collection.dart/ --adhoc-import lib/built_collection.dart

Features requests and bugs

Please file feature requests and bugs at the issue tracker.



[X] provide a back channel for the sandbox to change its own package config. [] find a way to unexport a library (can we enumerate all the symbols from a library and hide them?)

Changes and open questions

Variable shadowing

Variables need to be declared with var or final now. Each top level declaration spawns a new compilation unit. All compilation units are chained together. This means that you can freely redeclare variables. They will shadow each other. This can lead to unintended consequences though:

>>> var a = 1
>>> void ip() { print(a++); }
>>> ip()
>>> ip()
>>> var a = 1;
>>> ip()
>>> a

Old Scope behavior

The old behavior (non-shadowed, undeclared variables) is available using the scratch Scope.

>>> scratch.a = 1
>>> void ip() { print(++scratch.a); }
>>> ip()
>>> ip()
>>> scratch.a = 1
>>> ip()

Why can't I keep this default?

The Scope behavior is ideal, however, I don't know how to lift it into the global namespace. Before I was evaluating every expression and statement within the Scope, so you could access all its fields without qualification. However, with top-level declaration, this is not possible anymore. This would mean having different semantics:

>>> a = 1


>>> class X { void ip() { print(++scratch.a); } }

A solution would be to generate a global scope file that is constantly reloaded. This seems infeasible for more complex inputs and for redefinitions.

Export not import!

Because each top-level decl is its own compilation unit, imports only work within the same cell/input.

>>> import 'dart:io'; get pwd => Directory.current;
>>> pwd
Directory: '/Users/blackhc/IdeaProjects/dart_repl'
>>> Directory.current
Unhandled exception:
NoSuchMethodError: No top-level getter 'Directory' declared.

To make a library available to following cells, you have to use export.

>>>  export 'dart:io'
>>> Directory.current
Directory: '/Users/blackhc/IdeaProjects/dart_repl'



  • Initial version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dart_repl: "^0.11.1"

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

      import 'package:dart_repl/dart_repl.dart';
Version Uploaded Documentation Archive
0.11.1 Apr 19, 2017 Go to the documentation of dart_repl 0.11.1 Download dart_repl 0.11.1 archive
0.11.0 Apr 19, 2017 Go to the documentation of dart_repl 0.11.0 Download dart_repl 0.11.0 archive
0.10.0 Apr 19, 2017 Go to the documentation of dart_repl 0.10.0 Download dart_repl 0.10.0 archive
0.9.3 Jan 16, 2017 Go to the documentation of dart_repl 0.9.3 Download dart_repl 0.9.3 archive
0.9.2 Jan 16, 2017 Go to the documentation of dart_repl 0.9.2 Download dart_repl 0.9.2 archive
0.9.1 Jan 16, 2017 Go to the documentation of dart_repl 0.9.1 Download dart_repl 0.9.1 archive
0.9.0 Jan 15, 2017 Go to the documentation of dart_repl 0.9.0 Download dart_repl 0.9.0 archive


We analyzed this package on Jun 19, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3


Describes how popular the package is relative to other packages. [more]
0 / 100
Code health derived from static analysis. [more]
96 / 100
Reflects how tidy and up-to-date the package is. [more]
71 / 100
Overall score:
Weighted score of the above. [more]
Learn more about scoring.


Detected platforms: Flutter, other

Primary library: package:dart_repl/dart_repl.dart with components: io, isolate.


  • Homepage does not exists.

    We were unable to access https://blog.blackhc.net at the time of the analysis.

  • Use constrained dependencies.

    The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: vm_service_client.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 error 8 hints.

    Strong-mode analysis of lib/src/template/isolate.dart failed with the following error:

    line: 23 col: 8
    Target of URI doesn't exist: 'sandbox.dart'.

    Strong-mode analysis of lib/src/cell_type.dart gave the following hint:

    line: 4 col: 8
    Unused import: 'dart:io'.

    Similar analysis of the following files failed:

    • lib/src/sandbox_isolate.dart (hint)
    • lib/src/template/cell_template.dart (hint)
  • Package is getting outdated.

    The package was released 60 weeks ago.

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use dart_repl.dart.

  • Use analysis_options.yaml.

    Rename old .analysis_options file to analysis_options.yaml.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.0.0 <2.0.0
analyzer >=0.29.2 <0.30.0 0.29.11 0.32.1
args >=0.13.7 <0.14.0 0.13.7 1.4.3
dart_repl_sandbox >=0.11.1 <0.12.0 0.11.1
meta >=1.0.4 <2.0.0 1.1.5
package_resolver >=1.0.2 <2.0.0 1.0.3
pub_cache >=0.1.0 <0.2.0 0.1.1 0.2.0
vm_service_client 0.2.4
Transitive dependencies
async 1.13.3 2.0.7
charcode 1.1.1
cli_util 0.0.1+2 0.1.3
collection 1.14.10
convert 2.0.1
crypto 2.0.5
csslib 0.14.4
glob 1.1.5
html 0.13.3+1
http 0.11.3+16
http_parser 3.1.2
isolate 1.1.0 2.0.1
json_rpc_2 2.0.8
logging 0.11.3+1
package_config 1.0.3
path 1.6.1
plugin 0.2.0+2
pub_semver 1.4.1
source_span 1.4.0
stack_trace 1.9.2
stream_channel 1.6.7+1
string_scanner 1.0.2
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+8
web_socket_channel 1.0.8
when 0.2.0
which 0.1.3
yaml 2.1.14
Dev dependencies
test >=0.12.0 <0.13.0