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.
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.
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.
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');
}
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.
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.
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.
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() ?? ''.
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.
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.
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.
main.dartdartstdin.readLineSync()void main() {
print('Hello from Dart!');
print('Welcome to XCODX Online Compiler!');
var message = 'Dart is awesome!';
print(message);
}