mapListenable method

List<Widget> mapListenable(
  1. Widget? callback(
    1. T item
    )
)

Convert the list of Listenable to the list of widgets.

It not only converts, but also listens for changes in each item and rebuilds only that part of the item if there are changes in each item.

Easily create high performance lists.

callback with the content of the widget.

Implementation

List<Widget> mapListenable(Widget? Function(T item) callback) {
  return map((item) {
    return ListenableListener<T>(
      listenable: item,
      builder: (context, listenable) =>
          callback.call(listenable) ?? const SizedBox(),
    );
  }).toList();
}