@@ -16,7 +16,7 @@ class GFSlider extends StatefulWidget {
1616 this .autoPlayAnimationDuration = const Duration (milliseconds: 800 ),
1717 this .autoPlayCurve: Curves .fastOutSlowIn,
1818 this .pauseAutoPlayOnTouch,
19- this .enlargeCenterPage = false ,
19+ this .enlargeMainPage = false ,
2020 this .onPageChanged,
2121 this .scrollPhysics,
2222 this .scrollDirection: Axis .horizontal})
@@ -26,81 +26,50 @@ class GFSlider extends StatefulWidget {
2626 initialPage: enableInfiniteScroll ? realPage + initialPage : initialPage,
2727 );
2828
29- /// The widgets to be shown in the carousel .
29+ /// The widgets to be shown as sliders .
3030 final List <Widget > items;
3131
32- /// Set carousel height and overrides any existing [aspectRatio] .
32+ /// Set slide widget height and overrides any existing [aspectRatio] .
3333 final double height;
3434
35- /// Aspect ratio is used if no height have been declared.
36- ///
37- /// Defaults to 16:9 aspect ratio.
35+ /// Aspect ratio is used if no height have been declared. Defaults to 16:9 aspect ratio.
3836 final double aspectRatio;
3937
40- /// The fraction of the viewport that each page should occupy.
41- ///
42- /// Defaults to 0.8, which means each page fills 80% of the carousel.
38+ /// The fraction of the viewport that each page should occupy. Defaults to 0.8, which means each page fills 80% of the slide.
4339 final num viewportFraction;
4440
45- /// The initial page to show when first creating the [GFSlider] .
46- ///
47- /// Defaults to 0.
41+ /// The initial page to show when first creating the [GFSlider] . Defaults to 0.
4842 final num initialPage;
4943
5044 /// The actual index of the [PageView] .
51- ///
52- /// This value can be ignored unless you know the carousel will be scrolled
53- /// backwards more then 10000 pages.
54- /// Defaults to 10000 to simulate infinite backwards scrolling.
5545 final num realPage;
5646
57- ///Determines if carousel should loop infinitely or be limited to item length.
58- ///
59- ///Defaults to true, i.e. infinite loop.
47+ /// Determines if slides should loop infinitely or be limited to item length. Defaults to true, i.e. infinite loop.
6048 final bool enableInfiniteScroll;
6149
62- /// Reverse the order of items if set to true.
63- ///
64- /// Defaults to false.
50+ /// Reverse the order of items if set to true. Defaults to false.
6551 final bool reverse;
6652
67- /// Enables auto play, sliding one page at a time.
68- ///
69- /// Use [autoPlayInterval] to determent the frequency of slides.
70- /// Defaults to false.
53+ /// Enables auto play, sliding one page at a time. Use [autoPlayInterval] to determent the frequency of slides. Defaults to false.
7154 final bool autoPlay;
7255
73- /// Sets Duration to determent the frequency of slides when
74- ///
75- /// [autoPlay] is set to true.
76- /// Defaults to 4 seconds.
56+ /// Sets Duration to determent the frequency of slides when [autoPlay] is set to true. Defaults to 4 seconds.
7757 final Duration autoPlayInterval;
7858
79- /// The animation duration between two transitioning pages while in auto playback.
80- ///
81- /// Defaults to 800 ms.
59+ /// The animation duration between two transitioning pages while in auto playback. Defaults to 800 ms.
8260 final Duration autoPlayAnimationDuration;
8361
84- /// Determines the animation curve physics.
85- ///
86- /// Defaults to [Curves.fastOutSlowIn] .
62+ /// Determines the animation curve physics. Defaults to [Curves.fastOutSlowIn] .
8763 final Curve autoPlayCurve;
8864
89- /// Sets a timer on touch detected that pause the auto play with
90- /// the given [Duration] .
91- ///
92- /// Touch Detection is only active if [autoPlay] is true.
65+ /// Sets a timer on touch detected that pause the auto play with the given [Duration] . Touch Detection is only active if [autoPlay] is true.
9366 final Duration pauseAutoPlayOnTouch;
9467
9568 /// Determines if current page should be larger then the side images,
96- /// creating a feeling of depth in the carousel.
97- ///
98- /// Defaults to false.
99- final bool enlargeCenterPage;
69+ /// creating a feeling of depth in the carousel. Defaults to false.
70+ final bool enlargeMainPage;
10071
101- /// The axis along which the page view scrolls.
102- ///
103- /// Defaults to [Axis.horizontal] .
72+ /// The axis along which the page view scrolls. Defaults to [Axis.horizontal] .
10473 final Axis scrollDirection;
10574
10675 /// Called whenever the page in the center of the viewport changes.
@@ -166,10 +135,10 @@ class _GFSliderState extends State<GFSlider> with TickerProviderStateMixin {
166135 @override
167136 void initState () {
168137 super .initState ();
169- timer = getTimer ();
138+ timer = getPlayTimer ();
170139 }
171140
172- Timer getTimer () {
141+ Timer getPlayTimer () {
173142 return Timer .periodic (widget.autoPlayInterval, (_) {
174143 if (widget.autoPlay) {
175144 widget.pageController
@@ -181,11 +150,11 @@ class _GFSliderState extends State<GFSlider> with TickerProviderStateMixin {
181150 void pauseOnTouch () {
182151 timer.cancel ();
183152 timer = Timer (widget.pauseAutoPlayOnTouch, () {
184- timer = getTimer ();
153+ timer = getPlayTimer ();
185154 });
186155 }
187156
188- Widget getWrapper (Widget child) {
157+ Widget getPageWrapper (Widget child) {
189158 if (widget.height != null ) {
190159 final Widget wrapper = Container (height: widget.height, child: child);
191160 return widget.autoPlay && widget.pauseAutoPlayOnTouch != null
@@ -210,7 +179,7 @@ class _GFSliderState extends State<GFSlider> with TickerProviderStateMixin {
210179
211180 @override
212181 Widget build (BuildContext context) {
213- return getWrapper (PageView .builder (
182+ return getPageWrapper (PageView .builder (
214183 physics: widget.scrollPhysics,
215184 scrollDirection: widget.scrollDirection,
216185 controller: widget.pageController,
@@ -245,7 +214,7 @@ class _GFSliderState extends State<GFSlider> with TickerProviderStateMixin {
245214 final double height =
246215 widget.height ?? MediaQuery .of (context).size.width * (1 / widget.aspectRatio);
247216 final double distortionValue =
248- widget.enlargeCenterPage ? Curves .easeOut.transform (value) : 1.0 ;
217+ widget.enlargeMainPage ? Curves .easeOut.transform (value) : 1.0 ;
249218
250219 if (widget.scrollDirection == Axis .horizontal) {
251220 return Center (child: SizedBox (height: distortionValue * height, child: child));
0 commit comments