Defining Constants

Let’s learn how to define variables whose values can never be changed in a Dart program.

Overview

Sometimes we create a variable and assign it a very specific value with the intention of never changing the value. For the program to run successfully, it is of the utmost importance that the value of the variable remains the same throughout its lifetime. To create such a variable, the keywords final and const should be used. Before we get into what final and const actually do, we need to learn the difference between compile-time and runtime.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy