Yeah, the title. Is there any difference (other than design, obviously) when writing final
or not?
As Flutter framework is build around immutability, the final
keyword is a way to enforce that immutability. So it is help ensure the following of Flutter design patterns.
In other hand , the Dart compiler do some optimizations that would not be possible if variable was marker var
Both "final" and "const" keywords may improve performance and reduce APK size for applications built in Flutter. "const" Widget
s have a different lifespan that improves performance.
Using these keywords indeed does some good. Though final
specifically may be misleading, and the compiler often knows the variable is never reassigned without the keyword. The improvements might not be worth the time. It is a matter of personal taste
I personally stick to using them, because no matter how small it seems, all performance issues are known to stack up and snowball.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With