Dart Cheatsheet - Dart Syntax & Flutter Reference
This reference is for Dart developers building Flutter apps or backend services, centered on the syntax you write all day: null-safe variables (final/const vs late), functions and closures, classes with mixins, and async flow with Future/async/await. Unlike a flat Dart feature list, entries are grouped by the construct and flag null-safety behavior that trips people new from Java/JS. After reading you should be able to write null-safe chains without non-null assertions everywhere, compose classes with mixins, and handle asynchronous work with Future and async/await without blocking the UI thread.
Variables & Types 10
var name = 'Dart';String name = 'Dart';final name = 'Dart';const pi = 3.14;int? nullableInt;late String lateVar;dynamic anything = 42;List<int> numbers = [1, 2, 3];Map<String, int> ages = {'Alice': 25};Set<int> unique = {1, 2, 3};Functions & Closures 6
int add(int a, int b) => a + b;void greet(String name, [String? title]) { }void greet({required String name, int age = 0}) { }Function fn = (x) => x * 2;void Function(int) callback;typedef Comparator<T> = int Function(T a, T b);Classes & Mixins 7
class Person { String name; Person(this.name); }class Student extends Person { }class Flyable mixin Fly { }class Bird extends Animal with Flyable { }abstract class Shape { double area(); }class Singleton { static final instance = Singleton._(); Singleton._(); }class Immutable { final int value; const Immutable(this.value); }Null Safety 6
String? nullable;nullable?.lengthnullable ?? 'default'nullable!if (nullable != null) { nullable.length; }late String lateVar;Asynchronous 6
Future<int> fetchData() async { return 42; }int result = await fetchData();Stream<int> countStream() async* { yield 1; }await for (var value in stream) { }Future.wait([future1, future2]);Completer<int> completer = Completer();Collection Operations 8
list.where((x) => x > 5).toList()list.map((x) => x * 2).toList()list.reduce((a, b) => a + b)list.fold(0, (sum, x) => sum + x)list.any((x) => x > 0)list.every((x) => x > 0)list.sort((a, b) => a.compareTo(b))list.groupBy((x) => x.category)Tips
- Dart's null safety is a compile-time check; use ? and ?? to avoid runtime exceptions.
- async/await is core to asynchronous programming; avoid blocking the UI thread.
- mixin is Dart's way to achieve multiple inheritance; good for code reuse.
Official References
Each command links to its official documentation below, so you can verify the latest usage and read deeper.
Maintained by LaoHand
Publicly updated on Jul 21, 2026, continuously proofread against official docs.
Contact Us
Wrong command or description? Send us corrections, business inquiries or product feedback by email.
Contact Us