DartPad is an open source tool that lets you play with the Dart language in any modern browser. Many pages in this site—especially codelabs—have embedded DartPads. To open DartPad as a standalone web page, visit the DartPad site (dartpad.dev).
Here’s what DartPad looks like when configured to run Dart:
Library support
DartPad supports dart:*
core libraries marked as
multi-platform and web platform. When writing Flutter apps,
DartPad also supports the package:flutter
and dart:ui
libraries.
DartPad doesn’t support deferred loading or using packages from the pub.dev package repository besides the currently supported packages.
Getting started
To get familiar with DartPad, try running some samples and creating a simple command-line app.
Open DartPad and run a sample
-
Go to DartPad.
Dart code appears on the left, and a place for the output appears on the right.
-
Choose a Flutter sample such as Sunflower, using the Samples list at the upper right.
The rendered output appears to the right.
Create a command-line app
To create a simple command-line app, use New Pad.
-
Click the New Pad button, and confirm that you want to discard changes to the current pad.
-
Click the Dart logo, make sure that HTML support is disabled, and then click Create.
-
Change the code. For example, change the
main()
function to contain this code:for (final char in 'hello'.split('')) { print(char); }
As you type, DartPad shows hints, documentation, and autocomplete suggestions.
-
Click the Format button.
DartPad uses the Dart formatter to ensure that your code has proper indentation, white space, and line wrapping.
-
Run your app.
-
If you didn’t happen to have any bugs while you were entering the code, try introducing a bug.
For example, if you change
split
tospit
, you get warnings at the bottom right of the window. If you run the app, a compilation error appears in the console.
Checking Dart version info
The language features and APIs that DartPad supports depend on the Dart SDK version that DartPad is currently using. You can find this SDK version at the bottom right of DartPad.
Embedding DartPad in web pages
You can embed DartPad inside of web pages, customizing it to suit your use case. For example, the futures codelab contains multiple embedded DartPads labeled as examples and exercises.
For more information about how to use embedded DartPads, see best practices for using DartPad in tutorials.
For technical details on embedding DartPads, see the DartPad embedding guide.