Dart Fundamentals interview question · Most asked

What's the difference between final and const?

Create a free account to save this page, take notes and track your progress. Sign in

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

More most-asked Dart Fundamentals questions

← All Dart Fundamentals questions

Was this page helpful?