I am using VSCode for Mac to develop Flutter, so let’s get to the topic.
Programmers who don’t have a little code cleanliness aren’t good programmers, and the endless nesting of Flutter tends to be intimidating or crash.
I reviewed some of the code on the Flutter framework, as well as some of the official Flutter examples, and found that there is only one good Flutter nesting:
Use commas. Append a comma to the last entry of a function and format it (shift+ Alt +F in VSCode).
Let’s look at this example:
Of course, everything can not be generalised, for myself, for EdgeInsets and TextStyle, such as fewer parameters, a line of code display more clearly, the function of the last entry, do not use a comma, formatted, will also be clear.
Finally, I would like to say that everyone has their own style and habit of writing code. This article is just a little advice. Whatever style you like, you can continue your own style, as long as the code is smooth and easy to read.
Well, luckily SwiftUI doesn’t use semicolons or commas.