Search⌘ K
AI Features

Dart Before You Flutter

Explore the fundamentals of Dart and understand its role in powering Flutter. Learn about Dart's asynchronous operations, isolate model, and features that make UI development productive and efficient across platforms.

Overview

Flutter has been able to grab the attention of the development community by introducing a style that allows for expressive liberty, making it a joy to build UIs for mobile apps. It incorporates certain concepts familiar to modern development experiences like reactive programming and widget composition while using the Dart platform as its main base of operations.

Why use Dart with Flutter

The Flutter team evaluated more than a dozen languages and picked Dart because it matched the way they were building user interfaces. Let’s see what Dart offers and why it was chosen by Flutter.

Optimized for UI

  • Asynchronous operations let your program complete work while waiting for another operation to finish. Here are some common asynchronous operations:

    • Fetching data over a network
    • Writing to a database
    • Reading data from a file
  • Most computers, even on mobile platforms, have multi-core CPUs. To take advantage of all those cores, developers traditionally use shared-memory threads running concurrently. However, shared-state concurrency is error-prone and can lead to complicated code. Instead of threads, all Dart code runs inside of isolates. Each isolate has its own memory heap, ensuring that no isolate’s state is accessible from any other isolate.

  • A programming language optimized for building user interfaces with features for expanding collections, and for customizing the UI for each platform.

Productive development

  • Flutter has a hot reload feature that helps you quickly and easily experiment, build UIs, add features, and fix bugs. Hot reload works by injecting updated source code files into the running Dart Virtual Machine (VM). After the VM updates classes with the new versions of fields and functions, the Flutter framework automatically rebuilds the widget tree, allowing you to quickly view the effects of your changes.

  • Flutter provides static analysis which allows you to find problems before executing a single line of code. It’s a powerful tool used to prevent bugs and ensure that the code conforms to style guidelines.

Fast on all platforms

Dart has an AOT (Ahead of Time) compiler, which compiles to fast, predictable, native code that allows almost all of Flutter to be written in Dart. This not only makes Flutter fast but ensures that virtually everything (including all the widgets) can be customized.