Advertisement
FahimHoque

ListContainer

Dec 28th, 2021
628
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.98 KB | None | 0 0
  1. class ListContainer extends StatelessWidget {
  2.   final ListContainerData? data;
  3.   final bool isScrollable;
  4.   final bool isHorizontal;
  5.   final bool isDeletable;
  6.  
  7.   const ListContainer({
  8.     Key? key,
  9.     required this.data,
  10.     this.isScrollable = true,
  11.     this.isHorizontal = true,
  12.     this.isDeletable = false,
  13.   }) : super(key: key);
  14.  
  15.   @override
  16.   Widget build(BuildContext context) {
  17.     return ListView.builder(
  18.       shrinkWrap: true,
  19.       scrollDirection: isHorizontal ? Axis.horizontal : Axis.vertical,
  20.       physics: isScrollable == true
  21.           ? BouncingScrollPhysics()
  22.           : NeverScrollableScrollPhysics(),
  23.       itemCount: data!.items!.length,
  24.       itemBuilder: (context, index) {
  25.         return buildCard(
  26.           index,
  27.           data!.items![index],
  28.           data!.items!.length,
  29.         );
  30.       },
  31.     );
  32.   }
  33.  
  34.   Widget buildCard(int index, ListItem listItem, int listLenght) {
  35.     return ListCardHandler(listItem, isDeletable, index);
  36.   }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement