widgetMap<T> function
Maps each item in widgets through mapFunc and flattens the result.
Implementation
List<Widget> widgetMap<T>(List<T> widgets, List<Widget> Function(T) mapFunc) {
return [...widgets.map(mapFunc).expand((element) => element)];
}