Advertisement

Online Dart Compiler

Write, run and test Dart code online, right in your browser. This free online Dart compiler needs no installation or signup — just type your code and click Run.

Dart is a client-optimised language from Google and the language behind Flutter, used to build mobile, web and desktop apps from one codebase.

How to use the Dart compiler

  1. Write or paste your Dart code in the editor.
  2. If your program reads input, open the I/O tab and type it into the STDIN box (one value per line).
  3. Click Run — the output and any errors appear in the output panel.

Sample: read input in Dart

import 'dart:io';

void main() {
  String? name = stdin.readLineSync();
  print('Hello, $name!');
}

Paste this into the editor, type your name in the STDIN box and click Run.

More Dart examples to try

Lists and maps

Dart collections with arrow functions — the basis of most Flutter code.

void main() {
  final scores = {"Asha": 91, "Ravi": 64, "Meena": 85};
  final passed = scores.entries.where((e) => e.value >= 70).map((e) => e.key).toList();
  print("Passed: $passed");
  print("Highest: ${scores.values.reduce((a, b) => a > b ? a : b)}");
}

Classes and null safety

A class with a named constructor and a nullable field.

class User {
  final String name;
  final String? email;
  User(this.name, {this.email});

  String describe() => email == null ? name : '$name <$email>';
}

void main() {
  print(User('Asha', email: 'asha@example.com').describe());
  print(User('Ravi').describe());
}

Common Dart errors and how to fix them

A value of type 'String?' can't be assigned to a variable of type 'String'
The value may be null (e.g. stdin.readLineSync()). Use ?? '' for a default, or check for null first.
The method 'x' isn't defined for the type
The method name is misspelled or belongs to another type. Check the class and spelling.
Final variable 'x' can only be set once
Use var instead of final if the value needs to change.
FormatException: Invalid radix-10 number
int.parse received non-numeric text. Check STDIN, or use int.tryParse.

Frequently asked questions

Is this online Dart compiler free?

Yes. It is completely free to use, with no signup required to write and run code.

Do I need to install anything?

No. It all works from your web browser, so there is nothing to download or set up — it works on Windows, macOS, Linux, Chromebooks and phones.

How do I give input to my Dart program?

Before clicking Run, type the input into the STDIN box under the I/O tab, one value per line. Your program reads it as standard input, just like typing in a terminal.

Is this good for learning Dart?

Yes. It is ideal for practising exercises, testing small programs and trying out ideas from tutorials, because you can run code instantly without configuring an environment.

Other online compilers

Editor powered by OneCompiler.