Dart is the language Flutter uses: sound null safety (String vs String?), type inference (var, final), collections, and async/await on Futures. Learn Dart types and nulls before you memorize widget catalogs. The same language runs in Flutter tests and small CLI tools.
This Dart cheat sheet is written for people searching for a fast, accurate reference: students, junior developers, and teams shipping production software. Pin it, copy the snippets, and come back when syntax slips.
Quick reference
- final / const:
finalruntime once.constcompile-time.varinfers a mutable binding. - Null:
int? n. Usen ?? 0,n?.abs(),n!only when you know it is non-null. - late: Assigned before first read. Do not use
lateto hide missing initialization. - Collections:
<int>[],<String, int>{},list.where((x) => x > 0).toList(). - Functions:
int add(int a, int b) => a + b;named args{required this.title}. - async:
Future<String> load() async { return await http.get(...); }. - Stream: Many async values. Flutter uses streams in some plugins;
StreamBuilderin UI. - class: Constructors, named constructors,
factory. Mixins withwith.
Copy-paste examples
Null-safe parse and a Future
int.tryParse returns int?. Keep ! out of app code unless a failed parse is already impossible.
int parseQty(String? raw) {
final n = int.tryParse(raw ?? '');
return n == null || n < 0 ? 0 : n;
}
Future<String> loadTitle(int id) async {
await Future<void>.delayed(const Duration(milliseconds: 10));
return 'Project $id';
}Common mistakes
- Using
!on every nullable to “make the analyzer quiet.” - Mixing
Futurewithoutawaitand printingInstance of Future. - Mutable
varlists inconstwidgets — const requires const children. - Treating Dart as JavaScript (no
undefined; usenull).
FAQ
- Is Dart only for Flutter? Most jobs that mention Dart mean Flutter. Dart also runs on the VM for tools and servers, but the ecosystem is Flutter-heavy.
- var vs final vs const?
varreassignable inferred type.finalone assignment.constcompile-time constant objects (canonicalized).
- How is Dart typed? Sound static types with inference. At runtime, types are still there (unlike TypeScript erase-only) for many checks — but you still write null-safe code for the compiler.
Build with this stack
When a cheat sheet is not enough — you need a production app, a student FYP, or a custom dashboard — ArpaNeuro builds mobile app development and also sells ready-made source code. Request a quote and tell us the stack.
Browse software development services or the source code marketplace if you want a working codebase instead of starting from a blank file.