Advertisement
virtuoso_o

carousel

Nov 28th, 2022
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. StatefulBuilder(builder: (context, setState) {
  2. return CarouselSlider.builder(
  3. carouselController: carouselController,
  4. itemCount: model.advertList.length,
  5. itemBuilder: (context, index, i) {
  6. AdvertModel ad = model.advertList[index];
  7.  
  8. // model.determineCarouselLength(, type)
  9. return ad.advertMediaType!.mediaType == "video"
  10. ? AjeoVideoPlayer(
  11. videoUrl: ad.advertMedia!,
  12. viewModel: model,
  13. // type: e.advertMediaType!.mediaType!
  14. )
  15. : CarouselImage(
  16. size: size,
  17. e: ad,
  18. viewModel: model,
  19. );
  20.  
  21. },
  22. options: CarouselOptions(
  23. // onScrolled: ,
  24. height: 160.h,
  25.  
  26. aspectRatio: 16 / 9,
  27.  
  28. viewportFraction: 1.0,
  29. initialPage: 0,
  30. // enableInfiniteScroll: true,
  31. reverse: false,
  32. autoPlay: isPlaying,
  33. autoPlayInterval: model.carouselDuration,
  34. autoPlayAnimationDuration: const Duration(seconds: 4),
  35. autoPlayCurve: Curves.easeInOutQuart,
  36. enlargeCenterPage: true,
  37. onPageChanged: (index, reason) {
  38. model.setCurrentIndex(index);
  39. // setState(() {
  40. // model.carouselDuration = Duration(seconds: 40);
  41. // });
  42. log(model.carouselDuration.toString());
  43. },
  44. // onPageChanged: callbackFunction,
  45. scrollDirection: Axis.horizontal,
  46. ));
  47. }),
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement