| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 
 | import 'package:flutter/material.dart';import 'package:carousel_slider/carousel_slider.dart';
 
 import '../index.dart';
 
 
 class CarouselWidget extends StatelessWidget {
 const CarouselWidget(
 {Key? key,
 this.onPageChanged,
 this.onTap,
 required this.items,
 this.currentIndex,
 this.height,
 this.indicatorColor,
 this.indicatorCircle,
 this.indicatorAlignment,
 this.indicatorLeft,
 this.indicatorRight,
 this.indicatorBottom})
 : super(key: key);
 
 
 final Function(int, CarouselPageChangedReason)? onPageChanged;
 
 
 final Function(int, KeyValueModel)? onTap;
 
 
 final List<KeyValueModel> items;
 
 
 final int? currentIndex;
 
 
 final double? height;
 
 
 final Color? indicatorColor;
 
 
 final bool? indicatorCircle;
 
 
 final MainAxisAlignment? indicatorAlignment;
 
 
 final double? indicatorLeft, indicatorRight, indicatorBottom;
 
 Widget _buildView() {
 List<Widget> ws = [
 
 CarouselSlider(
 options: CarouselOptions(
 
 height: height,
 
 viewportFraction: 1,
 
 aspectRatio: 3.2 / 1,
 
 enlargeCenterPage: false,
 
 enableInfiniteScroll: true,
 
 autoPlay: true,
 
 onPageChanged: onPageChanged,
 ),
 items: <Widget>[
 for (var i = 0; i < items.length; i++)
 ImageWidget.url(
 items[i].value,
 fit: BoxFit.fill,
 ).onTap(
 () {
 if (onTap != null) onTap!(i, items[i]);
 },
 ),
 ],
 ),
 
 
 SliderIndicatorWidget(
 
 length: items.length,
 
 currentIndex: currentIndex ?? 0,
 
 color: indicatorColor ?? AppColors.background,
 
 isCircle: indicatorCircle ?? true,
 
 alignment: indicatorAlignment ?? MainAxisAlignment.center,
 ).positioned(
 left: indicatorLeft ?? 20,
 right: indicatorRight ?? 20,
 bottom: indicatorBottom ?? 10,
 ),
 ];
 
 return ws.toStack();
 }
 
 @override
 Widget build(BuildContext context) {
 return _buildView();
 }
 }
 
 |