Flutter cheat sheet

A scannable Flutter reference: 9 short snippets across 6 topics, each linking back to the lesson it came from.

At a glance

TopicWhat it covers
Setup and your first appInstall the Flutter SDK, understand what a project contains, and read the counter app that every new project startslesson
State, navigation and release buildsThe rule that keeps Flutter codebases sane: state lives above every widget that needs it and no higher. Local UI statelesson
Local persistence: shared_preferences, sqflite, Drift and HiveNote the difference between SharedPreferencesAsync and the legacy SharedPreferences.getInstance() cache: the async APIlesson
Performance, images and animationsFind rebuilds that matter, keep the frame budget, animate implicitly and with Hero transitions, and serve images at thelesson
CI/CD, flavors and store deploymentAutomate versioning from the CI run number for the build identifier and bump the user-facing version manually when youlesson
Next steps: Firebase, web and desktop targetsCheck every plugin's platform support before committing to a target. A single camera or Bluetooth dependency withoutlesson

Quick snippets

Setup and your first app

Install and check the toolchain

# macOS / Linux: download the SDK, then put it on PATH
export PATH="$PATH:$HOME/flutter/bin"

flutter doctor            # reports missing SDKs, licences, devices
flutter doctor --android-licenses
flutter devices           # emulators, simulators and physical phones

flutter create --org com.example --platforms=android,ios notes
cd notes
flutter run

Full lesson: Setup and your first app →

State, navigation and release builds

Building for release

flutter build appbundle --release --obfuscate --split-debug-info=build/symbols
flutter build apk --release --split-per-abi
flutter build ipa --release --export-method app-store
flutter build web --release --base-href /app/

Full lesson: State, navigation and release builds →

Local persistence: shared_preferences, sqflite, Drift and Hive

Choosing a store

final prefs = await SharedPreferences.getInstance();
await prefs.setBool('onboarding_done', true);
await prefs.setString('last_sync', DateTime.now().toIso8601String());

const storage = FlutterSecureStorage(
  aOptions: AndroidOptions(encryptedSharedPreferences: true),
);
await storage.write(key: 'access_token', value: token);

What goes wrong in production

// Cache the database handle; opening per query is expensive
AppDatabase? _db;
AppDatabase get db => _db ??= AppDatabase(
      LazyDatabase(() async {
        final dir = await getApplicationDocumentsDirectory();
        final file = File(p.join(dir.path, 'app.sqlite'));
        return NativeDatabase.createInBackground(file);
      }),
    );

Full lesson: Local persistence: shared_preferences, sqflite, Drift and Hive →

Performance, images and animations

Images and the frame budget

Image.network(
  url,
  width: 320,
  height: 200,
  fit: BoxFit.cover,
  cacheWidth: (320 * MediaQuery.devicePixelRatioOf(context)).round(),
  filterQuality: FilterQuality.medium,
  frameBuilder: (context, child, frame, wasSync) =>
      wasSync ? child : AnimatedOpacity(opacity: frame == null ? 0 : 1, duration: const Duration(milliseconds: 200), child: child),
  errorBuilder: (context, error, stack) => const ColoredBox(color: Color(0x11000000)),
)

Full lesson: Performance, images and animations →

CI/CD, flavors and store deployment

Flavors and environments

# Android: product flavors in android/app/build.gradle.kts
flutter build apk --flavor staging -t lib/main_staging.dart
flutter build appbundle --flavor production -t lib/main_production.dart

# iOS: schemes and configurations created in Xcode
flutter build ipa --flavor production -t lib/main_production.dart

Flavors and environments

// lib/config.dart: one compile-time source of truth
class Env {
  static const apiBase = String.fromEnvironment(
    'API_BASE',
    defaultValue: 'https://staging.api.example.com',
  );
  static const flavor = String.fromEnvironment('FLAVOR', defaultValue: 'staging');
  static bool get isProduction => flavor == 'production';
}

// build with: flutter build apk --dart-define=FLAVOR=production \
//   --dart-define=API_BASE=https://api.example.com

A release pipeline

# fastlane/Fastfile
default_platform(:android)

platform :android do
  lane :beta do
    gradle(task: "bundle", build_type: "Release", flavor: "production")
    upload_to_play_store(
      track: "internal",
      aab: "build/app/outputs/bundle/productionRelease/app-production-release.aab"
    )
  end
end

Full lesson: CI/CD, flavors and store deployment →

Next steps: Firebase, web and desktop targets

Firebase with FlutterFire

dart pub global activate flutterfire_cli
flutterfire configure --project=my-app   # writes firebase_options.dart

flutter pub add firebase_core firebase_auth cloud_firestore

Full lesson: Next steps: Firebase, web and desktop targets →

FAQ

Is this Flutter cheat sheet free to use?
Yes. No sign-up and no tracking: the page is static, every example is on the page itself, and you can print it or save it as a one-page reference.
Where do the examples come from?
Every snippet is taken from the 6 lessons of the Flutter course on this site, and each section links back to the lesson it was pulled from.
How do I go deeper than a cheat sheet?
Open the full Flutter course — it carries the worked explanations, the edge cases and the exercises behind every line here.

Android iOS React Native Kotlin Swift

Last refreshed 2026-09-27.