Skip to content

Commit ca5407b

Browse files
committed
gfcarousel pagnation issues fixed and gfbottomsheet controller issue fixed
1 parent dd44f0b commit ca5407b

File tree

2 files changed

+36
-37
lines changed

2 files changed

+36
-37
lines changed

lib/components/bottom_sheet/gf_bottom_sheet.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class GFBottomSheetController extends ValueNotifier<bool> {
258258

259259
// ignore: unnecessary_getters_setters
260260
double? get height => _height;
261-
bool? get isBottomSheetOpened => value;
261+
bool get isBottomSheetOpened => value;
262262
void hideBottomSheet() => value = false;
263263
void showBottomSheet() => value = true;
264264
}

lib/components/carousel/gf_carousel.dart

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class GFCarousel extends StatefulWidget {
5252
final num viewportFraction;
5353

5454
/// The initial page to show when first creating the [GFCarousel]. Defaults to 0.
55-
final num initialPage;
55+
final int initialPage;
5656

5757
/// Determines if slides should loop infinitely or be limited to item length. Defaults to true, i.e. infinite loop.
5858
final bool enableInfiniteScroll;
@@ -125,23 +125,24 @@ class _GFCarouselState extends State<GFCarousel> with TickerProviderStateMixin {
125125

126126
/// The actual index of the [PageView].
127127
int realPage = 10000;
128+
int? currentSlide;
128129

129130
@override
130131
void initState() {
131132
super.initState();
132133
realPage = widget.enableInfiniteScroll
133134
// ignore: avoid_as
134-
? realPage + (widget.initialPage as int)
135+
? realPage + widget.initialPage
135136
// ignore: avoid_as
136-
: widget.initialPage as int;
137+
: widget.initialPage;
137138
pageController = PageController(
138139
// ignore: avoid_as
139140
viewportFraction: widget.viewportFraction as double,
140141
initialPage: widget.enableInfiniteScroll
141142
// ignore: avoid_as
142-
? realPage + (widget.initialPage as int)
143+
? realPage + widget.initialPage
143144
// ignore: avoid_as
144-
: widget.initialPage as int,
145+
: widget.initialPage,
145146
);
146147
timer = getPlayTimer();
147148
}
@@ -189,8 +190,6 @@ class _GFCarouselState extends State<GFCarousel> with TickerProviderStateMixin {
189190
setState(() => currentSlide = index);
190191
}
191192

192-
int? currentSlide;
193-
194193
@override
195194
Widget build(BuildContext context) => Stack(
196195
children: <Widget>[
@@ -206,25 +205,23 @@ class _GFCarouselState extends State<GFCarousel> with TickerProviderStateMixin {
206205
: widget.items.length,
207206
onPageChanged: (int index) {
208207
int currentPage;
209-
// ignore: avoid_as
210-
currentPage = _getRealIndex(index + (widget.initialPage as int),
211-
realPage, widget.items.length);
208+
currentPage = _getRealIndex(
209+
index + widget.initialPage, realPage, widget.items.length);
212210
if (widget.onPageChanged != null) {
213211
widget.onPageChanged!(currentPage);
214212
}
215-
if (widget.pagination == true && widget.onPageChanged == null) {
213+
if (widget.pagination == true) {
216214
onPageSlide(currentPage);
217215
}
218216
},
219217
itemBuilder: (BuildContext context, int i) {
220-
final int index = _getRealIndex(
221-
// ignore: avoid_as
222-
i + (widget.initialPage as int),
218+
int index;
219+
index = _getRealIndex(
220+
i + widget.initialPage,
223221
realPage,
224222
widget.items.length,
225223
);
226-
227-
currentSlide = index;
224+
currentSlide = widget.initialPage;
228225
return AnimatedBuilder(
229226
animation: pageController,
230227
child: widget.items[index],
@@ -283,27 +280,29 @@ class _GFCarouselState extends State<GFCarousel> with TickerProviderStateMixin {
283280
child: Row(
284281
mainAxisAlignment: MainAxisAlignment.center,
285282
children: widget.map<Widget>(
286-
widget.items,
287-
(pagerIndex, url) => Container(
288-
width:
289-
widget.pagerSize == null ? 8.0 : widget.pagerSize,
290-
height:
291-
widget.pagerSize == null ? 8.0 : widget.pagerSize,
292-
margin: const EdgeInsets.symmetric(
293-
vertical: 10, horizontal: 2),
294-
decoration: BoxDecoration(
295-
shape: BoxShape.circle,
296-
color: currentSlide == pagerIndex
297-
? widget.activeIndicator == null
298-
? const Color.fromRGBO(0, 0, 0, 0.9)
299-
: widget.activeIndicator!
300-
: widget.passiveIndicator == null
301-
? const Color.fromRGBO(0, 0, 0, 0.4)
302-
: widget.passiveIndicator!,
283+
widget.items,
284+
(pagerIndex, url) => Container(
285+
width: widget.pagerSize == null
286+
? 8.0
287+
: widget.pagerSize,
288+
height: widget.pagerSize == null
289+
? 8.0
290+
: widget.pagerSize,
291+
margin: const EdgeInsets.symmetric(
292+
vertical: 10, horizontal: 2),
293+
decoration: BoxDecoration(
294+
shape: BoxShape.circle,
295+
color: currentSlide == pagerIndex
296+
? widget.activeIndicator == null
297+
? const Color.fromRGBO(0, 0, 0, 0.9)
298+
: widget.activeIndicator!
299+
: widget.passiveIndicator == null
300+
? const Color.fromRGBO(0, 0, 0, 0.4)
301+
: widget.passiveIndicator!,
302+
),
303+
)
304+
// ignore: avoid_as
303305
),
304-
),
305-
// ignore: avoid_as
306-
),
307306
),
308307
),
309308
)

0 commit comments

Comments
 (0)