What Language Is Flutter Written In? Dart, C++ and Native Compilation Explained
Flutter is written in two primary languages: the high-level framework uses Dart while the low-level engine uses C++, and Dart code compiles to native machine code for mobile/desktop or JavaScript/WebAssembly for web.
The flutter/flutter repository reveals a dual-language architecture that powers Google's UI toolkit. When developers ask what language Flutter is written in, the answer spans the Dart framework that developers interact with daily and the C++ engine that renders pixels and interfaces with the operating system. This design allows Flutter to deliver native performance while maintaining a single codebase.
Flutter's Dual-Language Architecture
Flutter's codebase is split between high-level UI logic and low-level system integration, with each layer written in a language optimized for its responsibilities.
The Framework Layer: Dart
The Flutter framework, located in packages/flutter/lib/src/, is written entirely in Dart. This layer provides the widget system, gesture recognition, and animation libraries that developers use to build applications.
Key files include:
packages/flutter/lib/src/widgets/framework.dart– Defines the coreWidget,Element, andRenderObjectclasses that form the foundation of Flutter's UI system.packages/flutter/lib/src/material/– Contains the Material Design widget implementations written in Dart.
The Engine Layer: C++
The Flutter engine, located in engine/src/flutter/, is written in C++. This layer handles rasterization, text layout, and platform-specific embedding. It compiles to native binaries for each supported platform.
Critical engine files include:
engine/src/flutter/vulkan/vulkan_swapchain.cc– Implements the Vulkan rendering backend in C++ for GPU acceleration.engine/src/flutter/vulkan/BUILD.gn– Defines the build configuration for compiling C++ engine components for different architectures.
According to the repository's README.md (lines 75-78), Flutter "code is powered by the world-class Dart programming language, which enables compilation to … JavaScript and WebAssembly for the web, as well as ARM and x64 binaries for mobile/desktop."
How Flutter Compiles to Native Code
Dart's compilation strategies translate Flutter code into platform-native formats without requiring JavaScript bridges or interpreters in release builds.
Ahead-of-Time (AOT) Compilation for Mobile and Desktop
For production releases, Dart uses ahead-of-time (AOT) compilation. The gen_snapshot tool compiles Dart code directly to native machine code for ARM64, ARMv7, or x86_64 architectures.
When you run:
flutter build apk --release
The command invokes the Dart AOT compiler to generate an ELF-format shared object (.so) for Android or a Mach-O binary for iOS. The resulting binary contains machine code that runs directly on the device's CPU without a Dart VM.
Just-in-Time (JIT) Compilation for Development
During development, Flutter uses just-in-time (JIT) compilation via the Dart VM. This enables hot reload, where changes to Dart source code reflect instantly without recompiling the entire binary.
The JIT compiler runs on the device or emulator, interpreting Dart bytecode while optimizing frequently executed paths to native code.
Web Compilation: JavaScript and WebAssembly
For web targets, Flutter employs two compilation paths:
- JavaScript: The
dart2jscompiler (andDDCfor development) transpiles Dart to optimized JavaScript. - WebAssembly: The engine's C++ code compiles to
.wasmmodules, while the Dart framework compiles to JavaScript that interfaces with these modules.
When executing:
flutter build web --release
The output includes main.dart.js and flutter_engine.wasm, placed in build/web/. The file engine/src/flutter/web_sdk/web_engine_tester/lib/static/host.dart illustrates how the engine exposes WebAssembly functionality to the browser environment.
Platform-Specific Native Outputs
Flutter produces distinct native artifacts for each target platform, all derived from the C++ engine and Dart framework sources.
| Platform | Native Output Format | Primary Implementation Language |
|---|---|---|
| iOS | ARM64 Mach-O binaries packaged in .framework bundles |
C++ compiled with Xcode; bridged via Objective-C/Swift |
| Android | ARM64 / x86 / x86_64 ELF shared objects (.so) |
C++ compiled via Android NDK; exposed through Java/Kotlin JNI |
| macOS | x64/ARM64 Mach-O executables and frameworks | C++ built with Clang/LLVM |
| Windows | x64 PE executables and DLLs | C++ built with MSVC |
| Linux | x64 ELF executables and shared libraries | C++ built with GCC/Clang |
| Web | JavaScript bundles and WebAssembly modules | C++ (Wasm) and Dart (JS) |
| Embedded (Fuchsia) | Platform-specific native binaries | C++ compiled with appropriate toolchain |
Key Source Files in the Flutter Repository
The following files demonstrate the dual-language implementation and compilation pipeline:
| Role | File Path | Significance |
|---|---|---|
| Framework Core | packages/flutter/lib/src/widgets/framework.dart |
Defines Widget, Element, and RenderObject classes; the heart of the Dart UI layer |
| Engine Rendering | engine/src/flutter/vulkan/vulkan_swapchain.cc |
C++ implementation of Vulkan rendering backend for GPU acceleration |
| Engine Build Config | engine/src/flutter/vulkan/BUILD.gn |
GN build file showing how C++ sources compile for each platform |
| Web Engine Bridge | engine/src/flutter/web_sdk/web_engine_tester/lib/static/host.dart |
Illustrates how the engine exposes WebAssembly functionality to browsers |
| Documentation | README.md (lines 75-78) |
Official statement that Flutter uses Dart and compiles to native code |
Practical Examples: From Dart Source to Native Binary
These examples illustrate the compilation pipeline from Dart source to platform-native artifacts.
Example 1: Dart Source Code
This is the developer-facing code written in Dart, located in lib/main.dart:
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text('Hello, Flutter!'),
),
),
);
}
}
Example 2: Compiling to Android Native Code
To compile the Dart code to native ARM64 binaries for Android:
flutter build apk --release
This command invokes the Dart AOT compiler to generate an ELF-format shared object (.so) file. The resulting binary contains machine code for the ARM64 architecture and links against the C++ engine library compiled via the Android NDK.
Example 3: Compiling to Web Targets
To compile for web deployment:
flutter build web --release
This produces main.dart.js (Dart compiled to JavaScript) and flutter_engine.wasm (C++ engine compiled to WebAssembly), placed in build/web/. The WebAssembly module handles rendering, while the JavaScript code manages the application logic and DOM interaction.
Summary
- Flutter's framework is written entirely in Dart, providing the widget system and developer APIs found in
packages/flutter/lib/src/widgets/framework.dart. - Flutter's engine is written in C++, handling rendering and platform integration via files like
engine/src/flutter/vulkan/vulkan_swapchain.cc. - Dart code compiles to native machine code (ARM64, x86_64) via AOT compilation for mobile and desktop platforms.
- During development, Dart uses JIT compilation to enable hot reload and rapid iteration.
- For web targets, Flutter compiles to JavaScript and WebAssembly, allowing execution in modern browsers without plugins.
Frequently Asked Questions
What is the primary programming language used in Flutter development?
Dart is the sole language developers use when writing Flutter applications. While the underlying engine uses C++, application developers write UI code, business logic, and state management entirely in Dart. The framework's source code in packages/flutter/lib/src/ demonstrates how sophisticated UI systems are built using Dart's object-oriented features and async/await patterns.
Does Flutter compile to native code or use an interpreter?
Flutter compiles to native machine code for production releases on mobile and desktop platforms. The Dart AOT (ahead-of-time) compiler transforms Dart source into ARM or x86_64 machine code that executes directly on the device's CPU without interpretation. For web platforms, Flutter compiles to JavaScript and WebAssembly, which browsers execute natively.
Why does Flutter use C++ for its engine instead of Dart?
C++ provides the low-level system access and deterministic performance required for graphics rendering and platform embedding. The engine must interface directly with GPU drivers (Vulkan, Metal, OpenGL) and operating system APIs, which are exposed as C/C++ interfaces. Writing the engine in C++ allows Flutter to share the same rendering codebase across iOS, Android, desktop, and embedded platforms while maintaining 60fps+ performance.
Can Flutter run on the web without JavaScript?
Flutter web applications require JavaScript to bootstrap and run the application logic. While the rendering engine compiles to WebAssembly (Wasm) for performance-critical graphics operations, the Dart framework and application code compile to JavaScript that executes in the browser. The file engine/src/flutter/web_sdk/web_engine_tester/lib/static/host.dart illustrates how the engine exposes WebAssembly functionality to the JavaScript environment, but JavaScript remains necessary for the application layer.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →