I have a list of Widgets and I want to use it as one of the children of a Column. Like this:
List<Widget> wList = [];
Column(
children([
Text("hi"),
//elements of wlist
])
)
I want to map it to use elements of list. What would be the syntax?
CodePudding user response:
3 dots operator will solve it shortly ... Try it like this
List<Widget> wList = [];
Column(
children([
Text("hi"),
...wList
])
)
CodePudding user response:
Just add it as
Column(
children: wList,
);
If you need additional widgets in said column with widget list you can always use it like:
Column(
children: [add widgets here] wList,
);
Or the other way around to add list before widgets in the column.
CodePudding user response:
You pass the list of widgets into a named argument called children. The syntax would be:
Column(
children: <Widget>[Text('Hello'), Text('World')]
)
With named arguments, you write the name of the argument and then a colon (:) and then the value you want to pass.