Dart overview Skip to main content dart.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic. Learn more OK, got it Dart Overview Docs Blog Community Learn Try Dart Get Dart search routine light_modeLight dark_modeDark night_sight_autoAutomatic apps Dart DartAPI DartPad pub.dev menu close asteriskOverview docsDocs newsmodeBlog publicCommunity play_lessonLearn Dart downloadGet Dart Languageexpand_moreIntroduction Variables Operators Comments Typesexpand_moreBuilt-in types Records Collections Generics Typedefs Type system Patternsexpand_moreOverview & usage Pattern types Applied tutorialopen_in_new Control flowexpand_moreLoops Branches Error handling Functions Metadata Libraries & imports Classes & objectsexpand_moreClasses Constructors Primary constructors Methods Extend a class Mixins Enums Dot shorthands Extension methods Extension types Callable objects Class modifiersexpand_moreOverview & usage Class modifiers for API maintainers Reference Concurrencyexpand_moreOverview Asynchronous programming Isolates Null safetyexpand_moreSound null safety Understanding null safety Dart keywords Language versioning Core librariesexpand_moreOverview dart:core dart:async dart:math dart:convert dart:io dart:js_interop Iterable collections Asynchronous programmingexpand_moreTutorial Futures and error handling Using streams Creating streams Effective Dartexpand_moreOverview Style Documentation Usage Design Packagesexpand_moreHow to use packages Creating packages Distributing CLI tools Publishing packages Writing package pages Workspaces (monorepo support) Hooks Package referenceexpand_moreDependencies Package layout conventions Pub environment variables Pubspec file Troubleshooting pub Verified publishers Security advisories Versioning Custom package repositories What not to commit Commonly used packages Dart team packages Developmentexpand_moreJSON serialization Number representation Google APIs Multi-platform apps Command-line & server appsexpand_moreOverview Fetch data from the internet Libraries & packages Google Cloud Web appsexpand_moreOverview Get started Deployment Libraries & packages Wasm compilation Environment declarations Interoperabilityexpand_moreC interop Objective-C & Swift interop Java & Kotlin interop JavaScript interopexpand_moreOverview Usage JS types Tutorials Past JS interop Web interop Tools & techniquesexpand_moreOverview Editors & debuggersexpand_moreIntelliJ & Android Studio VS Code Troubleshoot analyzer performance Dart DevTools DartPadexpand_moreOverview Troubleshooting DartPad Command-line toolsexpand_moreDart SDKexpand_moreOverview dart dart analyze dart build dart compile dart create dart doc dart fix dart format dart info dart install dart pub dart run dart test dartaotruntime Experiment flags Other command-line toolsexpand_morebuild_runner webdev Static analysisexpand_moreCustomizing static analysis Fixing type promotion failures Linter rules Analyzer plugins Diagnostic messages Testing & optimizationexpand_moreTesting Debugging web apps Learn Dartexpand_moreOverview Tutorial Build with AIexpand_moreDart and Flutter MCP serveropen_in_new Genkit for Dartopen_in_new Stay up to dateexpand_moreDart Blog Changelog What's new in the docs Resourcesexpand_moreLanguage cheatsheet Language specification Dart 3 migration guide Glossary Books Videos Related sitesexpand_moreAPI referenceopen_in_new DartPad (online editor)open_in_new Flutteropen_in_new Package siteopen_in_new listOn this page chevron_rightDart overview vertical_align_top Dart overview Dart: The language Dart: The libraries Dart: The platforms Learning Dart Dart 3.13 is here! Clean and lightweight code across every layer of Dart. Read the announcement. list On this page Dart: The language Dart: The libraries Dart: The platforms Learning Dart Dart overview A short introduction to Dart. more_vert copyCopy link docsView source bug_reportReport issue Dart is a client-optimized language for developing fast apps on any platform. Its goal is to offer the most productive programming language for multi-platform development, paired with a flexible execution runtime platform for app frameworks. Languages are defined by their technical envelope—the choices made during development that shape the capabilities and strengths of a language. Dart is designed for a technical envelope that's particularly suited to client development, prioritizing both development (sub-second stateful hot reload) and high-quality production experiences across a wide variety of compilation targets (web, mobile, and desktop). Dart also forms the foundation of Flutter. Dart provides the language and runtimes that power Flutter apps, but Dart also supports many core developer tasks like formatting, analyzing, and testing code. lightbulb New to programming? If you are new to programming, +some concepts on this page can be advanced. +Consider starting with a foundational introduction: Check out the Codelabs Dart tutorials for step-by-step guided basics. Take a look at the introductory Language Tour to learn fundamental syntax at your own pace. Dart: The language # The Dart language is type safe; it uses static type checking to ensure that a variable's value always matches the variable's static type. Sometimes, this is referred to as sound typing. Although types are mandatory, type annotations are optional because of type inference. The Dart typing system is also flexible, allowing the use of a dynamic type combined with runtime checks, which can be useful during experimentation or for code that needs to be especially dynamic. Dart has built-in sound null safety. This means values can't be null unless you say they can be. With sound null safety, Dart can protect you from null exceptions at runtime through static code analysis. Unlike many other null-safe languages, when Dart determines that a variable is non-nullable, that variable can never be null. If you inspect your running code in the debugger, you see that non-nullability is retained at runtime; hence sound null safety. The following code sample showcases several Dart language features, including libraries, async calls, nullable and non-nullable types, arrow syntax, generators, streams, and getters. To learn more about the language, check out the Dart language tour. import 'dart:math' show Random; void main() async { print('Compute π using the Monte Carlo method.'); await for (final estimate in computePi().take(100)) { print('π ≅ $estimate'); } } /// Generates a stream of increasingly accurate estimates of π. Stream<double> computePi({int batch = 100000}) async* { var total = 0; // Inferred to be of type int var count = 0; while (true) { final points = generateRandom().take(batch); final inside = points.where((p) => p.isInsideUnitCircle); total += batch; count += inside.length; final ratio = count / total; // Area of a circle is A = π⋅r², therefore π = A/r². // We consider only non-negative x and y (that is, the // first quadrant), which doesn't change the ratio. // So, when given random points with x ∈ [0, 1], // y ∈ [0, 1], the ratio of those inside the unit circle // should approach π / 4. Therefore, the value of π // should be: yield ratio * 4; } } Iterable<Point> generateRandom([int? seed]) sync* { final random = Random(seed); while (true) { yield Point(random.nextDouble(), random.nextDouble()); } } class Point { final double x; final double y; const Point(this.x, this.y); bool get isInsideUnitCircle => x * x + y * y <= 1; } infoNote This example is running in an embedded DartPad. You can also open this example in its own window. Dart: The libraries # Dart has a rich set of core libraries, providing essentials for many everyday programming tasks: Built-in types, collections, and other core functionality for every Dart program (dart:core) Richer collection types such as queues, linked lists, hashmaps, and binary trees (dart:collection) Encoders and decoders for converting between different data representations, including JSON and UTF-8 (dart:convert) Mathematical constants and functions, and random number generation (dart:math) Support for asynchronous programming, with classes such as Future and Stream (dart:async) Lists that efficiently handle fixed-sized data (for example, unsigned 8-byte integers) and SIMD numeric types (dart:typed_data) File, socket, HTTP, and other I/O support for non-web applications (dart:io) Foreign function interfaces for interoperability with other code that presents a C-style interface (dart:ffi) Concurrent programming using isolates—independent workers that are similar to threads but don't share memory, communicating only through messages (dart:isolate) HTML elements and other resources for web-based applications that need to interact with the browser and the Document Object Model (DOM) (dart:js_interop and package:web) Beyond the core libraries, many APIs are provided through a comprehensive set of packages. The Dart team publishes many useful supplementary packages, such as these: characters intl http crypto markdown Additionally, third-party publishers and the broader community publish thousands of packages, with support for features like these: XML Windows integration SQLite compression To see a series of working examples featuring the Dart core libraries, read the core library documentation. To find additional APIs, check out the commonly used packages page. Dart: The platforms # Dart's compiler technology lets you run code in different ways: Native platform: For apps targeting mobile and desktop devices, Dart includes both a Dart VM with just-in-time (JIT) compilation and an ahead-of-time (AOT) compiler for producing machine code. Web platform: For apps targeting the web, Dart can compile for development or production purposes. Its web compilers translate Dart into JavaScript or WebAssembly. The Flutter framework is a popular, multi-platform UI toolkit that's powered by the Dart platform, and that provides tooling and UI libraries to build UI experiences that run on iOS, Android, macOS, Windows, Linux, and the web. Dart Native (machine code JIT and AOT) # During development, a fast developer cycle is critical for iteration. The Dart VM offers a just-in-time compiler (JIT) with incremental recompilation (enabling hot reload), live metrics collections (powering DevTools), and rich debugging support. When apps are ready to be deployed to production—whether you're publishing to an app store or deploying to a production backend—the Dart ahead-of-time (AOT) compiler can compile to native ARM or x64 machine code. Your AOT-compiled app launches with consistent, short startup time. The AOT-compiled code runs inside an efficient Dart runtime that enforces the sound Dart type system and manages memory using fast object allocation and a generational garbage collector. Dart Web (JavaScript dev & prod and WebAssembly) # Dart Web enables running Dart code on web platforms powered by JavaScript. With Dart Web, you compile Dart code to JavaScript code, which in turn runs in a browser—for example, V8 inside Chrome. Alternatively, Dart code can be compiled to WebAssembly. Dart web contains three compilation modes: An incremental JavaScript development compiler enabling a fast developer cycle with incremental recompilation (enabling hot reload). An optimizing JavaScript production compiler which compiles Dart code to fast, compact, deployable JavaScript. These efficiencies come from techniques such as dead-code elimination. An optimizing WebAssembly (WasmGC) production compiler which compiles Dart code to super-fast, deployable WebAssembly GC code. More information: Build a web app with Dart dart compile js webdev tool Web deployment tips WebAssembly compilation The Dart runtime # Regardless of which platform you use or how you compile your code, executing the code requires a Dart runtime. This runtime is responsible for the following critical tasks: Managing memory: Dart uses a managed memory…