From e68a49498b4d84360c83ffe4d24e0e92308301ba Mon Sep 17 00:00:00 2001 From: al4nnw <65188332+al4nnw@users.noreply.github.com> Date: Sun, 27 Mar 2022 13:18:36 -0300 Subject: [PATCH] added a itemExtent variable To create the scaling effect, it's necessary to use the itemExtent value to perform calculations. It's easier to understand it using a variable to store the itemExtent value. --- example/lib/screens/complex.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/example/lib/screens/complex.dart b/example/lib/screens/complex.dart index c2c79e7..b4e46a7 100644 --- a/example/lib/screens/complex.dart +++ b/example/lib/screens/complex.dart @@ -14,6 +14,7 @@ class _ComplexState extends State { double _anchor = 0.0; bool _center = true; double _velocityFactor = 0.2; + final double _itemExtent = 120; late InfiniteScrollController _controller; @override @@ -39,7 +40,7 @@ class _ComplexState extends State { height: 200, child: InfiniteCarousel.builder( itemCount: kDemoImages.length, - itemExtent: 120, + itemExtent: _itemExtent, center: _center, anchor: _anchor, velocityFactor: _velocityFactor, @@ -54,13 +55,13 @@ class _ComplexState extends State { : null, controller: _controller, itemBuilder: (context, itemIndex, realIndex) { - final currentOffset = 120 * realIndex; + final currentOffset = _itemExtent * realIndex; return AnimatedBuilder( animation: _controller, builder: (context, child) { final diff = (_controller.offset - currentOffset); final maxPadding = 10.0; - final _carouselRatio = 120 / maxPadding; + final _carouselRatio = _itemExtent / maxPadding; return Padding( padding: EdgeInsets.only(