$for<T> function
ForBLoCWidget<T>
$for<T>(
- LiveData<
List< lv, {T> > - Key? key,
- Widget buildList(
- BuildContext context,
- List<
ItemViewHolder< listT> >
- Widget buildItem(
- BuildContext context,
- T value,
- int index
- Widget buildEmpty(
- BuildContext context,
- List<
T> list
Implementation
ForBLoCWidget<T> $for<T>(
LiveData<List<T>> lv, {
Key? key,
Widget Function(BuildContext context, List<ItemViewHolder<T>> list)? buildList,
Widget Function(BuildContext context, T value, int index)? buildItem,
Widget Function(BuildContext context, List<T> list)? buildEmpty,
}) {
buildList ??= (
BuildContext _context,
List<ItemViewHolder<T>> items,
) {
return ListView.builder(
itemCount: items.length,
itemBuilder: (context, i) => items[i].widget,
);
};
buildItem ??= (BuildContext _context, T value, int _index) {
return Text('$value');
};
return ForBLoCWidget<T>(
liveData: lv,
listBuilder: buildList,
itemBuilder: buildItem,
emptyBuilder: buildEmpty ?? (_, list) => EmptyWidget(key: key),
);
}