Getting Started with Flutter

This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production.

Flutter is Google’s open-source UI toolkit for building natively compiled applications for mobile, web, desktop and embedded targets from a single Dart codebase. The examples in this section target Flutter 3.47.9 (stable) with Dart 3.13.7, and build one running app, Trailhead — a hiking journal with a trail list from https://api.example.com/v1/trails, a trail detail screen, favourites, hike logging with a camera photo and a GPS position, and an offline cache of trails. If Dart is new to you, read Dart Language Essentials first or alongside this page.

What Flutter Is

Flutter is not a wrapper around native widgets and not a web view. It ships its own rendering engine and draws every pixel of the UI itself, as described in Architecture and Rendering. The consequences are the defining traits of the toolkit:

  • One UI, identical everywhere. A widget looks and behaves the same on Android, iOS, web, Windows, macOS and Linux, because the same code renders it.

  • Compiled, not interpreted. Release builds are compiled ahead of time to native ARM or x64 machine code; the web target compiles Dart to JavaScript or WebAssembly. Debug builds use a JIT virtual machine, which is what makes hot reload possible.

  • Everything is a widget. Layout, styling, gestures and animation are all expressed by composing small immutable widget objects (see Widgets and Layout).

  • Platform access through plugins. Camera, location, file system and the like come from packages that call into Kotlin, Swift or C++ behind a method channel or FFI (see Platform Integration).

Flutter Compared with the Alternatives

Aspect Flutter React Native Ionic and Capacitor Native (Kotlin, Swift)

Language

Dart

TypeScript and JavaScript

TypeScript with a web framework

Kotlin and Swift

UI rendering

Own engine (Impeller) draws all pixels

Real native views

Web view with HTML and CSS

Platform widgets

Look and feel

Same everywhere, Material or Cupertino styled

Platform native

Web styled, Ionic adapts per platform

Fully platform native

Reuse of web skills

Low

High (React)

Highest (web)

None

Targets

Mobile, web, desktop

Mobile, some web and desktop

Mobile and web (PWA)

One platform each

Performance ceiling

Near native, no bridge to a UI thread

Near native with the New Architecture

Web view bound

Best

Platform API access

Plugins, FFI, platform channels

Native modules

Capacitor plugins

Direct

Hot reload

Stateful hot reload

Fast Refresh

Live reload

Compose and SwiftUI previews

Choose Flutter when a single, pixel-consistent, animation-heavy UI across mobile and desktop matters more than reusing a web team’s skills. Choose React Native when the team already writes React, and Ionic with Capacitor when an existing web application must reach the app stores. Kotlin teams sharing business logic rather than UI should also consider Kotlin Multiplatform. The overview of all options is on Hybrid Apps.

Installing the SDK

The SDK is a Git checkout plus the Dart SDK it bundles. The official installation guide at https://docs.flutter.dev/get-started/install covers each operating system; the short version is:

  • macOS and Linux. Download the stable archive (or git clone https://github.com/flutter/flutter.git -b stable), extract it, and add flutter/bin to the PATH. On macOS also install Xcode (for iOS and macOS targets) and CocoaPods.

  • Windows. Extract the archive, add flutter\bin to PATH, and install Visual Studio with the Desktop development with C++ workload for Windows desktop builds.

  • All systems. Install Android Studio for the Android SDK, command-line tools and emulator, and use VS Code or Android Studio with the Flutter and Dart plugins as the editor.

flutter --version        # Flutter 3.47.9 channel stable, Dart 3.13.7
flutter channel          # stable, beta, master
flutter upgrade          # move to the latest release of the current channel

Pin the version per project with a version manager such as FVM, or in CI with the subosito/flutter-action GitHub action, so that every developer and every pipeline builds with the same SDK.

flutter doctor

flutter doctor inspects the machine and reports what is missing for each target.

flutter doctor -v
# [✓] Flutter (Channel stable, 3.47.9)
# [✓] Android toolchain - develop for Android devices
# [✓] Xcode - develop for iOS and macOS
# [✓] Chrome - develop for the web
# [✓] Android Studio
# [✓] Connected device (3 available)

Typical fixes are accepting the Android licences with flutter doctor --android-licenses, installing the Xcode command-line tools, or installing CocoaPods. Run the command again after each fix until every line you care about is green. A missing desktop toolchain does not matter if you only ship mobile.

Creating the Project

flutter create --org com.example --project-name trailhead --platforms=android,ios,web trailhead
cd trailhead
flutter run

flutter create generates a working counter app. The --org value becomes the Android application id and iOS bundle identifier prefix (com.example.trailhead), and --platforms limits which runner folders are created; more can be added later with flutter create --platforms=windows . inside the project.

Project Layout

Path Purpose

pubspec.yaml

Package manifest: name, version, SDK constraints, dependencies, assets and fonts.

pubspec.lock

Resolved dependency versions; commit it for applications.

analysis_options.yaml

Lint and analyzer configuration.

lib/

All Dart application code. lib/main.dart is the entry point.

test/

Unit and widget tests (see Testing).

integration_test/

End-to-end tests that run on a device or emulator.

android/

The Android runner: a Gradle project with an app module and the manifest.

ios/

The iOS runner: an Xcode workspace, Runner target and Podfile.

web/

index.html, manifest and icons for the web target.

assets/

Conventional folder for images and data files declared in pubspec.yaml.

The android/ and ios/ folders are ordinary native projects. You edit them for permissions, signing, app icons and native SDK configuration, and rarely for anything else (see Building and Releasing). A recommended Trailhead layout under lib/ is feature first:

lib/
  main.dart
  app.dart                  MaterialApp.router and theme
  features/
    trails/
      data/                 TrailRepository, TrailApi, Trail model
      presentation/         TrailListScreen, TrailDetailScreen
    favourites/
    hikes/
  core/                     networking, routing, theme

Dependencies in pubspec.yaml

name: trailhead
description: A hiking journal.
publish_to: none
version: 1.0.0+1

environment:
  sdk: ^3.13.0

dependencies:
  flutter:
    sdk: flutter
  go_router: ^18.1.4
  flutter_riverpod: ^3.5.0
  dio: ^5.11.1

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^6.0.0

flutter:
  uses-material-design: true

flutter pub add go_router edits the file and fetches the package; flutter pub get resolves what is already declared. The version is a name and a build number separated by a plus sign: the part after the plus becomes the Android versionCode and the iOS build number.

The Trailhead Hello Screen

Replace lib/main.dart with the first Trailhead screen. It uses Material 3, a const widget tree and a stateless widget.

import 'package:flutter/material.dart';

void main() {
  runApp(const TrailheadApp());
}

class TrailheadApp extends StatelessWidget {
  const TrailheadApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Trailhead',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.green),
        useMaterial3: true,
      ),
      home: const HelloScreen(),
    );
  }
}

class HelloScreen extends StatelessWidget {
  const HelloScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Trailhead')),
      body: const Center(
        child: Text('Your hiking journal starts here'),
      ),
    );
  }
}

Everything the user sees is built by build methods returning widgets: MaterialApp provides theming, navigation and localization; Scaffold provides the app bar and body slots. The next pages replace the placeholder with a real list.

Running the App

flutter devices                      # list targets
flutter emulators --launch Pixel_8   # start an Android emulator by id
flutter run -d <device-id>           # run on a specific target
flutter run -d chrome                # web
flutter run -d macos                 # desktop (also windows, linux)
flutter run --release                # profile with --profile, release with --release
  • Android emulator. Create an AVD in Android Studio’s Device Manager; use a system image with Google APIs.

  • iOS simulator. open -a Simulator on macOS, then flutter run.

  • Physical device. Android needs USB debugging enabled; iOS needs a development team set in Xcode signing settings.

  • Web and desktop. The same code runs in the browser or as a native desktop window; no emulator is involved.

Use debug mode for development, profile mode (never an emulator) for performance measurement, and release mode for what you ship. Debug builds are noticeably slower; do not judge performance from them.

Hot Reload and Hot Restart

Action What it does Keyboard in the terminal

Hot reload

Injects changed source into the running Dart VM and rebuilds the widget tree, keeping app state

r

Hot restart

Restarts the app from main, discarding state, but without a full native rebuild

R

Full restart

Stops and relaunches, including the native build

q, then flutter run

Hot reload is stateful: the counter on screen keeps its value. It does not re-run main, initState or static initializers, so changes to those need a hot restart. Changes to native code, pubspec.yaml assets in some cases, and plugin additions need a full restart.

DevTools

DevTools is the browser-based suite for debugging and profiling, opened from the IDE or with dart devtools.

  • The Flutter Inspector shows the widget tree and lets you select a widget on the device.

  • The Performance view shows frame timings on the UI and raster threads and highlights jank.

  • The Memory view tracks allocations and helps find leaks, and the Network view lists HTTP traffic.

  • The Logging and Debugger views show print output, breakpoints and exceptions.

Next Steps

Read Architecture and Rendering to understand what runApp sets in motion, then Widgets and Layout to build the trail list and detail screens.