The analyzer doesn’t say
final var is illegal.
but dart2js says
final var is illegal
What is correct? Why?
var means mutable variable with explicit
dynamic type specifier.
The explicit type specifier means that this is not possible specify another type in declaration.
val or immutable variable with unspecified type, with implicit
The implicit type specifier means that this is possible specify other type in declaration.
More precisely variable that declared as
val are the
variable at once.
It are variable because has the
But it are also
immutable value that can be retrieved from associated storage just once and can be used anywhere.
Now consider the following code:
final var foo;
This is the same as the following pseudo code:
immutable mutable dynamic foo;
Of course, this will not work.
Answered By – mezoni
Answer Checked By – David Marino (FlutterFixes Volunteer)