@@ -69,7 +69,7 @@ Add `flutter_carousel_widget` as a dependency in your `pubspec.yaml` file:
6969
7070``` dart
7171dependencies:
72- flutter_carousel_widget: ^latest_version
72+ flutter_carousel_widget: ^latest_version
7373```
7474
7575And import it:
@@ -86,25 +86,25 @@ Flutter Carousel is a carousel widget which supports infinite scrolling, auto sc
8686
8787``` dart
8888FlutterCarousel(
89- options: CarouselOptions(
90- height: 400.0,
91- showIndicator: true,
92- slideIndicator: CircularSlideIndicator(),
93- ),
94- items: [1,2,3,4,5].map((i) {
95- return Builder(
96- builder: (BuildContext context) {
97- return Container(
98- width: MediaQuery.of(context).size.width,
99- margin: EdgeInsets.symmetric(horizontal: 5.0),
100- decoration: BoxDecoration(
101- color: Colors.amber
102- ),
103- child: Text('text $i', style: TextStyle(fontSize: 16.0),)
104- );
105- },
106- );
107- }).toList(),
89+ options: CarouselOptions(
90+ height: 400.0,
91+ showIndicator: true,
92+ slideIndicator: CircularSlideIndicator(),
93+ ),
94+ items: [1,2,3,4,5].map((i) {
95+ return Builder(
96+ builder: (BuildContext context) {
97+ return Container(
98+ width: MediaQuery.of(context).size.width,
99+ margin: EdgeInsets.symmetric(horizontal: 5.0),
100+ decoration: BoxDecoration(
101+ color: Colors.amber
102+ ),
103+ child: Text('text $i', style: TextStyle(fontSize: 16.0),)
104+ );
105+ },
106+ );
107+ }).toList(),
108108)
109109```
110110
@@ -114,57 +114,57 @@ Expandable Carousel is a carousel widget which automatically expands to the size
114114
115115``` dart
116116ExpandableCarousel(
117- options: CarouselOptions(
118- autoPlay: true,
119- autoPlayInterval: const Duration(seconds: 2),
120- ),
121- items: [1,2,3,4,5].map((i) {
122- return Builder(
123- builder: (BuildContext context) {
124- return Container(
125- width: MediaQuery.of(context).size.width,
126- margin: EdgeInsets.symmetric(horizontal: 5.0),
127- decoration: BoxDecoration(
128- color: Colors.amber
129- ),
130- child: Text('text $i', style: TextStyle(fontSize: 16.0),)
131- );
132- },
133- );
134- }).toList(),
117+ options: CarouselOptions(
118+ autoPlay: true,
119+ autoPlayInterval: const Duration(seconds: 2),
120+ ),
121+ items: [1,2,3,4,5].map((i) {
122+ return Builder(
123+ builder: (BuildContext context) {
124+ return Container(
125+ width: MediaQuery.of(context).size.width,
126+ margin: EdgeInsets.symmetric(horizontal: 5.0),
127+ decoration: BoxDecoration(
128+ color: Colors.amber
129+ ),
130+ child: Text('text $i', style: TextStyle(fontSize: 16.0),)
131+ );
132+ },
133+ );
134+ }).toList(),
135135)
136136```
137137
138138### Option Customization
139139
140140``` dart
141141FlutterCarousel(
142- items: items,
143- options: CarouselOptions(
144- height: 400.0,
145- aspectRatio: 16 / 9,
146- viewportFraction: 1.0,
147- initialPage: 0,
148- enableInfiniteScroll: true,
149- reverse: false,
150- autoPlay: false,
151- autoPlayInterval: const Duration(seconds: 2),
152- autoPlayAnimationDuration: const Duration(milliseconds: 800),
153- autoPlayCurve: Curves.fastOutSlowIn,
154- enlargeCenterPage: false,
155- controller: CarouselController(),
156- onPageChanged: callbackFunction,
157- pageSnapping: true,
158- scrollDirection: Axis.horizontal,
159- pauseAutoPlayOnTouch: true,
160- pauseAutoPlayOnManualNavigate: true,
161- pauseAutoPlayInFiniteScroll: false,
162- enlargeStrategy: CenterPageEnlargeStrategy.scale,
163- disableCenter: false,
164- showIndicator: true,
165- floatingIndicator = true,
166- slideIndicator: CircularSlideIndicator(),
167- )
142+ items: items,
143+ options: CarouselOptions(
144+ height: 400.0,
145+ aspectRatio: 16 / 9,
146+ viewportFraction: 1.0,
147+ initialPage: 0,
148+ enableInfiniteScroll: true,
149+ reverse: false,
150+ autoPlay: false,
151+ autoPlayInterval: const Duration(seconds: 2),
152+ autoPlayAnimationDuration: const Duration(milliseconds: 800),
153+ autoPlayCurve: Curves.fastOutSlowIn,
154+ enlargeCenterPage: false,
155+ controller: CarouselController(),
156+ onPageChanged: callbackFunction,
157+ pageSnapping: true,
158+ scrollDirection: Axis.horizontal,
159+ pauseAutoPlayOnTouch: true,
160+ pauseAutoPlayOnManualNavigate: true,
161+ pauseAutoPlayInFiniteScroll: false,
162+ enlargeStrategy: CenterPageEnlargeStrategy.scale,
163+ disableCenter: false,
164+ showIndicator: true,
165+ floatingIndicator = true,
166+ slideIndicator: CircularSlideIndicator(),
167+ )
168168)
169169```
170170
@@ -174,21 +174,21 @@ This method will save memory by building items once it becomes necessary. This w
174174
175175``` dart
176176FlutterCarousel.builder(
177- itemCount: 15,
178- itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) =>
179- Container(
180- child: Text(itemIndex.toString()),
181- ),
177+ itemCount: 15,
178+ itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) =>
179+ Container(
180+ child: Text(itemIndex.toString()),
181+ ),
182182)
183183```
184184
185185``` dart
186186ExpandableCarousel.builder(
187- itemCount: 15,
188- itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) =>
189- Container(
190- child: Text(itemIndex.toString()),
191- ),
187+ itemCount: 15,
188+ itemBuilder: (BuildContext context, int itemIndex, int pageViewIndex) =>
189+ Container(
190+ child: Text(itemIndex.toString()),
191+ ),
192192)
193193```
194194
@@ -200,26 +200,26 @@ In order to manually control the pageview's position, you can create your own `C
200200class CarouselDemo extends StatelessWidget {
201201 CarouselController buttonCarouselController = CarouselController();
202202
203- @override
203+ @override
204204 Widget build(BuildContext context) => Column(
205- children: [
206- FlutterCarousel(
207- items: child,
208- options: CarouselOptions(
209- autoPlay: false,
210- controller: buttonCarouselController,
211- enlargeCenterPage: true,
212- viewportFraction: 0.9,
213- aspectRatio: 2.0,
214- initialPage: 2,
215- ),
216- ),
217- RaisedButton(
218- onPressed: () => buttonCarouselController.nextPage(
219- duration: Duration(milliseconds: 300), curve: Curves.linear),
220- child: Text('→'),
221- )
222- ]
205+ children: [
206+ FlutterCarousel(
207+ items: child,
208+ options: CarouselOptions(
209+ autoPlay: false,
210+ controller: buttonCarouselController,
211+ enlargeCenterPage: true,
212+ viewportFraction: 0.9,
213+ aspectRatio: 2.0,
214+ initialPage: 2,
215+ ),
216+ ),
217+ RaisedButton(
218+ onPressed: () => buttonCarouselController.nextPage(
219+ duration: Duration(milliseconds: 300), curve: Curves.linear),
220+ child: Text('→'),
221+ )
222+ ]
223223 );
224224}
225225```
@@ -265,10 +265,8 @@ class SlidePercentageIndicator implements SlideIndicator {
265265 @override
266266 Widget build(int currentPage, double pageDelta, int itemCount) {
267267 if (itemCount < 2) return const SizedBox.shrink();
268-
269268 final step = 100 / (itemCount - 1);
270269 final percentage = step * (pageDelta + currentPage);
271-
272270 return Center(
273271 child: Text(
274272 '${percentage.toStringAsFixed(decimalPlaces)}%',
0 commit comments