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(),
];
}
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(),
]
);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.