In short, because when you mark the top-most widget in the tree with a const keyword, all its inner widgets will also use a const constructor, so there is no need to add those extra const keywords. If a inner widget does not have a const constructor, then your code won't compile.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi. Why the first one is bad and the second one is good? Can you give me an explanation? Tks.
In short, because when you mark the top-most widget in the tree with a
const
keyword, all its inner widgets will also use aconst
constructor, so there is no need to add those extraconst
keywords. If a inner widget does not have aconst
constructor, then your code won't compile.