Issue
Let's say we have a column. Is it possible to add several widgets using one method? Something like .addAll()?
Column(
children: [
SomeWidget(),
_someBigWidgetMethod(),
_severalWidgets(),
]
)
_severalWidgets(){
return [
Widget(),
Widget(),
Widget(),
];
}
Solution
In order to add all items in a list into another list, you can use the ... operator:
List<Widget> _myMethod() => [Widget1(), Widget2(), Widget3(), Widget4()];
Widget build(BuildContext context) {
return Column(
children: [
SomeWidget(),
..._myMethod(),
]
);
}
Answered By - h8moss
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.