Dart final and const keyword

Dart supports the assignment of constant value to a variable.

  1. final keyword

  2. const keyword

  1. Final Keyword

  • The final keyword is used to keep the values of the variable and it cannot be altered in future, also we can not process any kind of the performance in the variable.

  • Syntax

        // Without datatype
        final variable_name;
    
        // With datatype
        final data_type  variable_name;
    
    1. Const Keyword

  • The Const keyword in Dart exactly same as like the final keyword. The only difference between final and const is that the const makes the variable constant from compile-time only.
  •     // Without datatype
        const variable_name;
    
        // With datatype
        const data_type  variable_name;