You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Widget constructors expect children in inconsistent ways #241
Some widgets (eg: Container) require a name child: argument to specify their children. Others (eg: Flex) take their children as the first argument. This inconsistency is confusing - especially as I switch between different container widgets.
Comment by abarth Thursday Oct 29, 2015 at 20:48 GMT
Yeah, the pattern we've been using is that if you take one widget as a child, you use the name child. If you take a list, then you use a positional argument. Are you suggesting that we make the list widgets use the name child too? Maybe children?
Comment by ianloic Monday Nov 02, 2015 at 18:21 GMT
I don't have a concrete suggestion other than it's a little confusing. Perhaps make the list widgets use children so that I'm forced to be explicit everywhere.
I think we should just always use named arguments for children, since the children argument often takes up many lines of code and usually reads best when it's the last argument passed to a constructor.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
FlutterIssues commentedon Nov 9, 2015
Thursday Oct 29, 2015 at 20:48 GMT
Yeah, the pattern we've been using is that if you take one widget as a child, you use the name
child. If you take a list, then you use a positional argument. Are you suggesting that we make the list widgets use the namechildtoo? Maybechildren?FlutterIssues commentedon Nov 9, 2015
Monday Nov 02, 2015 at 18:21 GMT
I don't have a concrete suggestion other than it's a little confusing. Perhaps make the list widgets use children so that I'm forced to be explicit everywhere.
tvolkert commentedon Nov 30, 2015
I think we should just always use named arguments for children, since the children argument often takes up many lines of code and usually reads best when it's the last argument passed to a constructor.
abarth commentedon Jan 11, 2016
Will do.
Use a named argument for Widget children
github-actions commentedon Aug 17, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.