Posts

Showing posts from January 26, 2019

What's with the final/const craze in Flutter?

Image
3 Java have final as well as Dart, but as far as I have seen, most Java people avoid using it all the time, since it can make your code less readable. For example, final is used all the time in class constants such as public static final int , but most people avoid using it in a method variable, since it's just seen as "excessive code correctness" by many developers, adding to boilerplate code. C++ also has const and it can get crazy with it: char ** const * const x // declare x as const pointer to const pointer to pointer to char Now I am starting to learn Flutter and I am seeing final and const all over the place. Are those really necessary, like when they say: Fields in a Widget subclass are always marked "final". Or can they be treated as "excess of code correctness" and be removed? Sorry if maybe my question is too stupid, I am really new to Dart and Flutter and I don't know all the side effects/benefits of using final an