diff --git a/lib/shimmer.dart b/lib/shimmer.dart index 724eeac..d5a8858 100644 --- a/lib/shimmer.dart +++ b/lib/shimmer.dart @@ -47,6 +47,9 @@ enum ShimmerDirection { ltr, rtl, ttb, btt } /// [enabled] controls if shimmer effect is active. When set to false the animation /// is paused /// +/// [slanted] controls if shimmer effect is slanted or straight. When set to false, +/// the effect plays horizontally if direction is ShimmerDirection.ltr or ShimmerDirection.rtl, +/// or else, the effect plays vertically if direction is ShimmerDirection.ttb or ShimmerDirection.btt /// /// ## Pro tips: /// @@ -63,6 +66,7 @@ class Shimmer extends StatefulWidget { final Gradient gradient; final int loop; final bool enabled; + final bool slanted; const Shimmer({ Key? key, @@ -72,6 +76,7 @@ class Shimmer extends StatefulWidget { this.period = const Duration(milliseconds: 1500), this.loop = 0, this.enabled = true, + this.slanted = true, }) : super(key: key); /// @@ -88,9 +93,20 @@ class Shimmer extends StatefulWidget { this.direction = ShimmerDirection.ltr, this.loop = 0, this.enabled = true, + this.slanted = true, }) : gradient = LinearGradient( - begin: Alignment.topLeft, - end: Alignment.centerRight, + begin: slanted + ? Alignment.topLeft + : direction == ShimmerDirection.ltr || + direction == ShimmerDirection.rtl + ? Alignment.centerLeft + : Alignment.topCenter, + end: slanted + ? Alignment.centerRight + : direction == ShimmerDirection.ltr || + direction == ShimmerDirection.rtl + ? Alignment.centerRight + : Alignment.bottomCenter, colors: [ baseColor, baseColor, @@ -143,9 +159,9 @@ class _ShimmerState extends State with SingleTickerProviderStateMixin { _controller.forward(from: 0.0); } }); - if (widget.enabled) { - _controller.forward(); - } + if (widget.enabled) { + _controller.forward(); + } } @override