Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/src/carousel_pro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class Carousel extends StatefulWidget {
//On image change event, passes previous image index and current image index as arguments
final void Function(int, int) onImageChange;

final ScrollPhysics physics;

final PageController controller;

Carousel({
this.images,
this.animationCurve = Curves.ease,
Expand Down Expand Up @@ -122,6 +126,8 @@ class Carousel extends StatefulWidget {
this.onImageTap,
this.onImageChange,
this.defaultImage,
this.physics,
this.controller,
});

@override
Expand All @@ -131,12 +137,14 @@ class Carousel extends StatefulWidget {
class CarouselState extends State<Carousel> {
Timer timer;
int _currentImageIndex = 0;
PageController _controller = PageController();
PageController _controller;

@override
void initState() {
super.initState();

if (_controller == null) {
_controller = widget.controller ?? PageController();
}
if (widget.images != null && widget.images.isNotEmpty) {
if (widget.autoplay) {
timer = Timer.periodic(widget.autoplayDuration, (_) {
Expand Down Expand Up @@ -312,7 +320,7 @@ class CarouselState extends State<Carousel> {
child: Builder(
builder: (_) {
Widget pageView = PageView(
physics: AlwaysScrollableScrollPhysics(),
physics: AlwaysScrollableScrollPhysics(parent: widget.physics),
controller: _controller,
children: listImages,
onPageChanged: (currentPage) {
Expand Down
67 changes: 37 additions & 30 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,49 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0"
version: "2.5.0-nullsafety.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
version: "1.15.0-nullsafety.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -45,35 +66,21 @@ packages:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.5"
version: "0.12.10-nullsafety.1"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.3.0-nullsafety.3"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.3"
version: "1.8.0-nullsafety.1"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -85,56 +92,56 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
version: "1.8.0-nullsafety.2"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "1.1.0-nullsafety.1"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.5"
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.3.0-nullsafety.3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
version: "2.1.0-nullsafety.3"
sdks:
dart: ">=2.2.2 <3.0.0"
dart: ">=2.10.0-110 <2.11.0"
flutter: ">=1.2.0 <2.0.0"