What is the difference between final and const in Dart?

Answer

Both final and const declare variables that cannot be reassigned, but they differ in when the value is determined. A final variable is assigned once at runtime — its value can be computed when the program runs (e.g., from a function call or user input). A const variable must have a value known at compile time and creates a deeply immutable, canonicalized object. Using const for widgets and values that never change improves Flutter rendering performance.