Skip to content

Commit

Permalink
Bumped to version 2.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nixrajput committed Jun 18, 2024
1 parent 66311fe commit d046d84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
2 changes: 2 additions & 0 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ class _ExpandableCarouselDemoState extends State<ExpandableCarouselDemo> {
ExpandableCarousel(
options: ExpandableCarouselOptions(
// viewportFraction: 1.0,
enableInfiniteScroll: false,
// initialPage: 3,
autoPlay: true,
controller: _controller,
floatingIndicator: false,
Expand Down
26 changes: 14 additions & 12 deletions lib/src/_expandable_carousel_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_carousel_widget/src/components/overflow_page.dart';
import 'package:flutter_carousel_widget/src/enums/carousel_page_changed_reason.dart';
import 'package:flutter_carousel_widget/src/helpers/flutter_carousel_controller.dart';
import 'package:flutter_carousel_widget/src/helpers/flutter_carousel_options.dart';
import 'package:flutter_carousel_widget/src/helpers/flutter_carousel_state.dart';
import 'package:flutter_carousel_widget/src/helpers/flutter_expandable_carousel_controller.dart';
import 'package:flutter_carousel_widget/src/helpers/flutter_expandable_carousel_options.dart';
import 'package:flutter_carousel_widget/src/helpers/flutter_expandable_carousel_state.dart';
import 'package:flutter_carousel_widget/src/typedefs/widget_builder.dart';
import 'package:flutter_carousel_widget/src/utils/flutter_carousel_utils.dart';

Expand Down Expand Up @@ -52,18 +52,19 @@ class ExpandableCarousel extends StatefulWidget {
final List<Widget>? items;

/// [ExpandableCarouselOptions] to create a [ExpandableCarouselState] with
final CarouselOptions options;
final ExpandableCarouselOptions options;

@override
ExpandableCarouselState createState() => ExpandableCarouselState();
ExpandableCarouselWidgetState createState() =>
ExpandableCarouselWidgetState();
}

class ExpandableCarouselState extends State<ExpandableCarousel>
class ExpandableCarouselWidgetState extends State<ExpandableCarousel>
with TickerProviderStateMixin {
/// mode is related to why the page is being changed
CarouselPageChangedReason mode = CarouselPageChangedReason.controller;

CarouselState? _carouselState;
ExpandableCarouselState? _carouselState;
int _currentPage = 0;
bool _firstPageLoaded = false;
PageController? _pageController;
Expand All @@ -73,7 +74,7 @@ class ExpandableCarouselState extends State<ExpandableCarousel>
late List<double> _sizes;
Timer? _timer;

CarouselOptions get options => widget.options;
ExpandableCarouselOptions get options => widget.options;

bool get isBuilder => widget.itemBuilder != null;

Expand Down Expand Up @@ -155,7 +156,7 @@ class ExpandableCarouselState extends State<ExpandableCarousel>
void initState() {
super.initState();

_carouselState = CarouselState(
_carouselState = ExpandableCarouselState(
options,
_clearTimer,
_resumeTimer,
Expand Down Expand Up @@ -202,10 +203,10 @@ class ExpandableCarouselState extends State<ExpandableCarousel>
super.dispose();
}

CarouselControllerImpl get carouselController =>
ExpandableCarouselControllerImpl get carouselController =>
widget.options.controller != null
? widget.options.controller as CarouselControllerImpl
: CarouselController() as CarouselControllerImpl;
? widget.options.controller as ExpandableCarouselControllerImpl
: ExpandableCarouselController() as ExpandableCarouselControllerImpl;

/// Timer
Timer? _getTimer() {
Expand All @@ -218,6 +219,7 @@ class ExpandableCarouselState extends State<ExpandableCarousel>

var previousReason = mode;
_changeMode(CarouselPageChangedReason.timed);

var nextPage = _carouselState!.pageController!.page!.round() + 1;
var itemCount = widget.itemCount ?? widget.items!.length;

Expand Down
6 changes: 2 additions & 4 deletions lib/src/_flutter_carousel_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ class FlutterCarouselState extends State<FlutterCarousel>
var previousReason = changeReasonMode;
changeMode(CarouselPageChangedReason.timed);

var itemCount = widget.itemCount ?? widget.items!.length;
var nextPage = _carouselState!.pageController!.page!.round() + 1;
var itemCount = widget.itemCount ?? widget.items!.length;

if (nextPage >= itemCount &&
widget.options.enableInfiniteScroll == false) {
Expand Down Expand Up @@ -432,10 +432,8 @@ class FlutterCarouselState extends State<FlutterCarousel>

/// The method to build the slide indicator
Widget _buildSlideIndicator() {
final _newCurrentPage =
(widget.options.initialPage + _currentPage) % widget.itemCount!;
return widget.options.slideIndicator!.build(
_newCurrentPage,
(widget.options.initialPage + _currentPage) % widget.itemCount!,
_pageDelta,
widget.itemCount!,
);
Expand Down

0 comments on commit d046d84

Please sign in to comment.