Advertisement
muhaiminurabir

vertical listview flutter

Jun 17th, 2025
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.14 KB | None | 0 0
  1.   Widget cartList() {
  2.     return context.watch<CartProvider>().cartResponse != null &&
  3.             context.watch<CartProvider>().cartResponse?.items != null &&
  4.             context.watch<CartProvider>().cartResponse!.items!.isNotEmpty
  5.         ? ListView.builder(
  6.           shrinkWrap: true,
  7.           scrollDirection: Axis.vertical,
  8.           itemCount: context.watch<CartProvider>().cartResponse?.items?.length,
  9.           itemBuilder: (BuildContext context, int index) {
  10.             return Row(
  11.               mainAxisSize: MainAxisSize.min,
  12.               mainAxisAlignment: MainAxisAlignment.spaceBetween,
  13.               children: [
  14.                 Expanded(
  15.                   child: Text(
  16.                     context
  17.                             .watch<CartProvider>()
  18.                             .cartResponse
  19.                             ?.items
  20.                             ?.elementAt(index)
  21.                             ?.productName ??
  22.                         "",
  23.                     style: GoogleFonts.roboto(
  24.                       fontSize: 14,
  25.                       fontWeight: FontWeight.w400,
  26.                       color: ProjectColors().blue3,
  27.                     ),
  28.                     maxLines: 1,
  29.                     overflow: TextOverflow.ellipsis,
  30.                     softWrap: true,
  31.                     textAlign: TextAlign.start,
  32.                   ),
  33.                 ),
  34.                 Text(
  35.                   context
  36.                           .watch<CartProvider>()
  37.                           .cartResponse
  38.                           ?.items
  39.                           ?.elementAt(index)
  40.                           ?.totalPrice ??
  41.                       "0",
  42.                   style: GoogleFonts.roboto(
  43.                     fontSize: 14,
  44.                     fontWeight: FontWeight.w500,
  45.                     color: ProjectColors().blue3,
  46.                   ),
  47.                   maxLines: 1,
  48.                   overflow: TextOverflow.ellipsis,
  49.                   softWrap: true,
  50.                   textAlign: TextAlign.start,
  51.                 ),
  52.               ],
  53.             );
  54.           },
  55.         )
  56.         : ColorLoader();
  57.   }
  58.  
Tags: listview
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement