Final vs const in Dart

Last reviewed in January 2020 by Frank Treacy

What's the difference between final and const in Dart?

Easy!

Final means single-assignment.

Const means immutable.

Let's see an example:

final _final = [2, 3];
const _const = [2, 3];
_final = [4,5]; // ERROR: can't re-assign
_final.add(6); // OK: can mutate
_const.add(6); // ERROR: can't mutate
Want to know EVERYTHING about Dart constructors? Check out Deconstructing Dart Constructors!

The best from the Flutter-verse in 3 minutes or less? Join Snacks!

Delivered twice monthly. No link walls. No spam. EVER.