Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

const vs final flutter

final variable can only be set once and it is initialized when accessed.
(for example from code section below if you use the value of 
biggestNumberOndice only then the value will be initialized and 
memory will be assigned).

const is internally final in nature but the main difference is that 
its compile time constant which is initialized during compilation even
if you don't use its value it will get initialized and will take space
in memory.

Variable from classes can be final but not constant and if you want a
constant at class level make it static const.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #const #final #flutter
ADD COMMENT
Topic
Name
3+5 =