Advertisement
muhaiminurabir

horizontal listview flutter

Jun 17th, 2025
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 5.37 KB | None | 0 0
  1.  LimitedBox(
  2.               maxHeight: 100,
  3.               child: ListView.builder(
  4.                 shrinkWrap: true,
  5.                 scrollDirection: Axis.horizontal,
  6.                 itemCount:
  7.                     context
  8.                         .watch<CommonProvider>()
  9.                         .productDetailsResponse
  10.                         ?.data
  11.                         ?.relatedItems
  12.                         ?.data
  13.                         ?.length,
  14.                 itemBuilder: (BuildContext context, int position) {
  15.                   return GestureDetector(
  16.                     onTap: () {
  17.                       Navigator.of(context).push(
  18.                         MaterialPageRoute(
  19.                           builder:
  20.                               (context) => ProductDetailsPage(
  21.                                 args: {
  22.                                   "id":
  23.                                       context
  24.                                           .read<CommonProvider>()
  25.                                           .productDetailsResponse
  26.                                           ?.data
  27.                                           ?.relatedItems
  28.                                           ?.data?[position]
  29.                                           ?.id,
  30.                                 },
  31.                               ),
  32.                         ),
  33.                       );
  34.                     },
  35.                     child: Card(
  36.                       color: ProjectColors().white,
  37.                       elevation: 0,
  38.                       shape: RoundedRectangleBorder(
  39.                         side: BorderSide(
  40.                           width: 1,
  41.                           color: ProjectColors().white,
  42.                         ),
  43.                         borderRadius: BorderRadius.all(Radius.circular(10)),
  44.                       ),
  45.                       margin: EdgeInsets.all(5),
  46.                       child: Padding(
  47.                         padding: EdgeInsets.all(0),
  48.                         child: SizedBox(
  49.                           width: 56,
  50.                           height: 56,
  51.                           child: Column(
  52.                             crossAxisAlignment: CrossAxisAlignment.start,
  53.                             children: <Widget>[
  54.                               CircleAvatar(
  55.                                 radius: 28,
  56.                                 child: CachedNetworkImage(
  57.                                   height: 60,
  58.                                   width: 60,
  59.                                   imageUrl:
  60.                                       context
  61.                                           .watch<CommonProvider>()
  62.                                           .productDetailsResponse
  63.                                           ?.data
  64.                                           ?.relatedItems
  65.                                           ?.data?[position]
  66.                                           ?.imageUrl ??
  67.                                       "",
  68.                                   placeholder:
  69.                                       (context, url) => Image.asset(
  70.                                         "assets/images/placeholder_image.png",
  71.                                         height: 60,
  72.                                         width: 60,
  73.                                         fit: BoxFit.fill,
  74.                                         scale: 10,
  75.                                       ),
  76.                                   errorWidget:
  77.                                       (context, url, error) => Image.asset(
  78.                                         "assets/images/placeholder_image.png",
  79.                                         height: 60,
  80.                                         width: 60,
  81.                                         fit: BoxFit.fill,
  82.                                         scale: 10,
  83.                                       ),
  84.                                   fit: BoxFit.cover,
  85.                                   imageBuilder:
  86.                                       (context, imageProvider) => CircleAvatar(
  87.                                         backgroundImage: imageProvider,
  88.                                       ),
  89.                                 ),
  90.                               ),
  91.                               Text(
  92.                                 context
  93.                                         .watch<CommonProvider>()
  94.                                         .productDetailsResponse
  95.                                         ?.data
  96.                                         ?.relatedItems
  97.                                         ?.data?[position]
  98.                                         ?.name ??
  99.                                     "",
  100.                                 style: GoogleFonts.roboto(
  101.                                   fontSize: 12,
  102.                                   fontWeight: FontWeight.w500,
  103.                                   color: ProjectColors().blue2,
  104.                                 ),
  105.                                 maxLines: 1,
  106.                                 overflow: TextOverflow.ellipsis,
  107.                                 textAlign: TextAlign.center,
  108.                               ),
  109.                             ],
  110.                           ),
  111.                         ),
  112.                       ),
  113.                     ),
  114.                   );
  115.                 },
  116.               ),
  117.             )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement