XCODX |

Dart Online Compiler & Interpreter

Select Language
Online Code Compiler
Full HTML IDE
Py main.py
Program Output Ready
  Welcome to XCODX Online Compiler

  Quick Start:
  Ctrl+Enter  Run code
  Ctrl+S      Save / Download
  Ctrl+L      Clear output

  Select a language and start coding.
Success
Operation completed

About Dart

Dart is a client-optimised language created by Google and first released in 2011, best known today as the language behind the Flutter UI toolkit. It is statically typed with sound null safety, compiles ahead-of-time to fast native code, and reads like a cleaned-up blend of Java and JavaScript. While most developers meet Dart through Flutter, it is a capable general-purpose language for command-line tools and, increasingly in 2026, server-side backends built with frameworks such as Dart Frog and Serverpod. On XCODX it runs with dart run against the core libraries, so you can practise syntax, null safety, and algorithms in the browser with no Flutter or SDK install.

Hello World in Dart

import 'dart:math';

void main() {
  final scores = [42, 88, 71, 95, 60];

  final total = scores.reduce((a, b) => a + b);
  final average = total / scores.length;
  final best = scores.reduce(max);

  print('Scores:  $scores');
  print('Average: ${average.toStringAsFixed(1)}');
  print('Highest: $best');

  final passed = scores.where((s) => s >= 70).length;
  print('$passed of ${scores.length} scored 70 or above');
}

When to use Dart

Dart's strengths are a clean, familiar syntax, sound null safety that catches whole classes of errors at compile time, and one codebase that can target mobile, web, desktop, and native binaries. Choose it when building Flutter apps, or when you want a single typed language across a full stack now that server frameworks have matured. It is a poor fit for data science and machine learning, where its library ecosystem is thin next to Python's.

Common questions

Can I add pub packages or use Flutter in the XCODX Dart compiler?

No. The sandbox runs dart run against the core libraries -- dart:core, dart:io, and dart:math -- with no pub add and no network to fetch packages, and Flutter is unavailable because it needs its own SDK and a rendering surface. Anything in the standard core libraries works, but pub.dev dependencies do not. Install the Dart SDK locally for package-based projects.

How do I read input in Dart?

Import 'dart:io' and call stdin.readLineSync(), which returns a nullable String?. In XCODX you type into the live terminal or the Stdin Box and press Enter, then use int.parse(...) or int.tryParse(...) to convert numbers. Because the result can be null at end of input, handle that with ?? or an explicit null check before using it.

Why does stdin.readLineSync() return null in Dart?

Under Dart's sound null safety, readLineSync() is typed String? because it yields null when it reaches end of input with no line. Beginners often copy old null-unsafe examples and hit a type error assigning it to a plain String. Fix it by writing String? name = stdin.readLineSync(); or supplying a default with stdin.readLineSync() ?? ''.

What is sound null safety in Dart?

Sound null safety means a normal type like String can never hold null; if a value might be absent you must mark it String?, and the compiler forces you to handle the null case. This removes most null-reference crashes before the program even runs. It is enforced in the sandbox, so watch the ? and ! operators when reading input or working with maps.

Can I use Dart without Flutter?

Yes. Dart is a full general-purpose language: it powers command-line tools, compiles to standalone native executables with dart compile exe, and runs server backends through frameworks such as Dart Frog and Serverpod. The XCODX sandbox itself runs plain Dart with no Flutter involved. Flutter is simply the best-known thing built with Dart, not a requirement.

Is Dart the same as JavaScript?

No, although Dart can compile to JavaScript for the web. Dart is statically typed with sound null safety and ahead-of-time native compilation, while JavaScript is dynamically typed and runs directly in browsers and Node. They share C-style syntax so the two feel familiar, but Dart's type checking catches errors that JavaScript would only reveal at runtime.

How Dart runs on XCODX

Sandbox filename
main.dart
Entry point
single main source file
Editor grammar
dart
Reading stdin
stdin.readLineSync()
Input delivery
live WebSocket stream
Prompt flushing
flush manually before reading input
Compile limit
10 s
Run limit
3 s batch · up to 3 min live
Memory
256 MB per stage
Max source
50,000 characters

Default program on this page

void main() {
  print('Hello from Dart!');
  print('Welcome to XCODX Online Compiler!');
  var message = 'Dart is awesome!';
  print(message);
}