Dart Fundamentals interview question · Most asked
What's the difference between final and const?
Summary
Both are single-assignment. final values may be computed at runtime; const values are compile-time constants and const collections/objects are deeply immutable and canonicalised.
Longer Answer
In Flutter, const widgets can be reused without rebuilding, which helps performance.
Key Points
- final: runtime, once.
- const: compile time, deeply immutable.
- const objects are canonicalised.
Deep dive: Dart Fundamentals: Variables