|
|
@ -13,7 +13,7 @@ class CarouselIndicator extends StatefulWidget {
|
|
|
|
final double space;
|
|
|
|
final double space;
|
|
|
|
|
|
|
|
|
|
|
|
/// count of indicator
|
|
|
|
/// count of indicator
|
|
|
|
final int count;
|
|
|
|
final int? count;
|
|
|
|
|
|
|
|
|
|
|
|
/// active color
|
|
|
|
/// active color
|
|
|
|
final Color activeColor;
|
|
|
|
final Color activeColor;
|
|
|
@ -27,21 +27,21 @@ class CarouselIndicator extends StatefulWidget {
|
|
|
|
/// duration for slide animation
|
|
|
|
/// duration for slide animation
|
|
|
|
final int animationDuration;
|
|
|
|
final int animationDuration;
|
|
|
|
|
|
|
|
|
|
|
|
final int index;
|
|
|
|
final int? index;
|
|
|
|
|
|
|
|
|
|
|
|
final Function(int index) onClick;
|
|
|
|
final Function(int index)? onClick;
|
|
|
|
|
|
|
|
|
|
|
|
CarouselIndicator({
|
|
|
|
CarouselIndicator({
|
|
|
|
Key key,
|
|
|
|
Key? key,
|
|
|
|
this.width: 20.0,
|
|
|
|
this.width= 20.0,
|
|
|
|
this.height: 6,
|
|
|
|
this.height= 6,
|
|
|
|
this.space: 5.0,
|
|
|
|
this.space= 5.0,
|
|
|
|
this.count,
|
|
|
|
this.count,
|
|
|
|
this.cornerRadius: 6,
|
|
|
|
this.cornerRadius= 6,
|
|
|
|
this.animationDuration: 300,
|
|
|
|
this.animationDuration= 300,
|
|
|
|
this.color: Colors.white30,
|
|
|
|
this.color= Colors.white30,
|
|
|
|
this.index,
|
|
|
|
this.index,
|
|
|
|
this.activeColor: Colors.white,
|
|
|
|
this.activeColor= Colors.white,
|
|
|
|
this.onClick
|
|
|
|
this.onClick
|
|
|
|
}) : assert(count != null && count != 0),
|
|
|
|
}) : assert(count != null && count != 0),
|
|
|
|
assert(index != null && index >= 0),
|
|
|
|
assert(index != null && index >= 0),
|
|
|
@ -56,13 +56,13 @@ class CarouselIndicator extends StatefulWidget {
|
|
|
|
class _CarouselIndicatorState extends State<CarouselIndicator>
|
|
|
|
class _CarouselIndicatorState extends State<CarouselIndicator>
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
with TickerProviderStateMixin {
|
|
|
|
/// [Tween] object of type double
|
|
|
|
/// [Tween] object of type double
|
|
|
|
Tween<double> _tween;
|
|
|
|
late Tween<double> _tween;
|
|
|
|
|
|
|
|
|
|
|
|
/// [AnimationController] object
|
|
|
|
/// [AnimationController] object
|
|
|
|
AnimationController _animationController;
|
|
|
|
late AnimationController _animationController;
|
|
|
|
|
|
|
|
|
|
|
|
/// [Aniamtion] object
|
|
|
|
/// [Aniamtion] object
|
|
|
|
Animation _animation;
|
|
|
|
late Animation _animation;
|
|
|
|
|
|
|
|
|
|
|
|
/// [Paint] object to paint our indicator
|
|
|
|
/// [Paint] object to paint our indicator
|
|
|
|
Paint _paint = new Paint();
|
|
|
|
Paint _paint = new Paint();
|
|
|
@ -75,7 +75,7 @@ class _CarouselIndicatorState extends State<CarouselIndicator>
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget child = new SizedBox(
|
|
|
|
Widget child = new SizedBox(
|
|
|
|
width: widget.count * widget.width + (widget.count - 1) * widget.space,
|
|
|
|
width: widget.count! * widget.width! + (widget.count! - 1) * widget.space,
|
|
|
|
height: widget.height,
|
|
|
|
height: widget.height,
|
|
|
|
child: CustomPaint(
|
|
|
|
child: CustomPaint(
|
|
|
|
painter: _createPainer(),
|
|
|
|
painter: _createPainer(),
|
|
|
@ -86,7 +86,7 @@ class _CarouselIndicatorState extends State<CarouselIndicator>
|
|
|
|
child: child,
|
|
|
|
child: child,
|
|
|
|
onTap: (){
|
|
|
|
onTap: (){
|
|
|
|
if(widget.onClick != null)
|
|
|
|
if(widget.onClick != null)
|
|
|
|
widget.onClick(0);
|
|
|
|
widget.onClick!(0);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|