Flutter & Dart (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Dart Concurrency: Event Loop, Microtask Queue, Futures, Streams, and Isolates.
senior LevelMost AskedEvent LoopData Structures
In Simple Words: Dart is single-threaded by default, operating on an Event Loop:
- Microtask Queue: Short internal tasks executed before the next event loop iteration.
- Event Queue: User inputs, network socket I/O, timers, and filesystem events.
- Isolates: To run heavy computational tasks (e.g. image filtering, parsing a 50MB JSON file) without stuttering the 60 FPS UI thread, Dart spawns Isolates:
- Isolates have completely separate memory heaps (no shared state, zero thread locks).
- Communicate strictly via message passing (
SendPort/ReceivePortorIsolate.run()).