I,m a newbie to flutter .I'm confused about when to use child and children.In many tutorial i'm seeing that they are using child and children as nested . How to get used with it?
CodePudding user response:
Its depends on widget like if you use ElevatedButton
widget it takes just one child means that it just directly can have one child but if we use a Row
as child of that button then row can have multiple of widgets as list which means it can handle multiple widgets
CodePudding user response:
Some widgets, like Row
, Column
, Stack
, ListView
etc.. Are designed to take a list of widgets (in the children argument) and arrange them accordingly. Others, like Container
, SizedBox
, Expanded
are designed to manipulate a single child widget. The most common ones like the ones I listed, you just end up memorizing if you start building apps with Flutter because they're so common.
But if you're ever not sure, your IDE should tell you which arguments the widget expects if you hover over it or cmd
/ctrl
click to jump to the source code.