widgetMap<T> static method
Maps a list of objects to a list of widgets using a mapping function.
Returns a new list of widgets where each object in the input list is mapped to a list of widgets using the provided mapping function.
Example usage:
List<String> items = ['Item 1', 'Item 2', 'Item 3'];
List<Widget> mappedWidgets = WidgetHelper.widgetMap(
items,
(item) => [Text(item), SizedBox(height: 10)],
);
Implementation
static List<Widget> widgetMap<T>(
List<T> widgets,
List<Widget> Function(T) mapFunc,
) {
return [
...widgets.map(mapFunc).expand((element) => element),
];
}