Can you differentiate between ‘const’ and ‘final’ in Dart?

In Dart, ‘final’ is used to declare a variable that can be set only once. ‘Const’ is used for compile-time constants, meaning the value is determined at compile-time and cannot be changed.

Candidates should be able to explain scenarios where each would be used, emphasizing ‘const’ for compile-time constants and ‘final’ for run-time constants.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *