Skip to content

Commit ba5eedb

Browse files
authored
Fixes last item size when ExpandableCarousel has no padsEnds (#61)
* fix: last item size in ExpandableCarousel * chore: upgrade pubspec.yaml version
1 parent 499d9e9 commit ba5eedb

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

lib/src/_expandable_carousel_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class _ExpandableCarouselWidgetState extends State<ExpandableCarousel>
220220

221221
// Calculate the actual index in case of infinite scrolling
222222
var actualIndex = getRealIndex(
223-
pageIndex.floor() + _carouselState!.initialPage, // Floor the page index
223+
pageIndex.round() + _carouselState!.initialPage, // Round the page index
224224
_carouselState!.realPage, // Initial real page
225225
widget.itemCount!, // Total number of items
226226
);
@@ -232,7 +232,7 @@ class _ExpandableCarouselWidgetState extends State<ExpandableCarousel>
232232
_firstPageLoaded = true; // Set first page loaded flag
233233
_previousPage = _currentPage; // Update previous page
234234
_currentPage = actualIndex; // Update current page
235-
_pageDelta = pageIndex - pageIndex.floor(); // Calculate delta
235+
_pageDelta = pageIndex - pageIndex.round(); // Calculate delta
236236
});
237237
}
238238
});

lib/src/_flutter_carousel_widget.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class _FlutterCarouselState extends State<FlutterCarousel>
103103

104104
// Calculate the actual index in case of infinite scrolling
105105
var actualIndex = getRealIndex(
106-
pageIndex.floor() + _carouselState!.initialPage, // Floor the page index
106+
pageIndex.round() + _carouselState!.initialPage, // Round the page index
107107
_carouselState!.realPage, // Initial real page
108108
widget.itemCount!, // Total number of items
109109
);
@@ -113,7 +113,7 @@ class _FlutterCarouselState extends State<FlutterCarousel>
113113
if (mounted) {
114114
setState(() {
115115
_currentPage = actualIndex; // Update current page
116-
_pageDelta = pageIndex - pageIndex.floor(); // Calculate delta
116+
_pageDelta = pageIndex - pageIndex.round(); // Calculate delta
117117
});
118118
}
119119
});

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: flutter_carousel_widget
22
description: A customizable Flutter carousel widget with infinite scrolling, auto-scrolling, pre-built indicators, expandable widgets, auto-sized child support, and enlarged center page.
33

4-
version: 3.1.0
4+
version: 3.1.1
55

66
homepage: https://pub.dev/packages/flutter_carousel_widget
77
repository: https://github.com/nixrajput/flutter_carousel_widget

0 commit comments

Comments
 (0)