From 1b2c51fd1f91ae3fd32626afcceaa27c582d7b5b Mon Sep 17 00:00:00 2001 From: Dane Mackier Date: Mon, 24 Jun 2024 11:16:23 +0200 Subject: [PATCH] fix: adds corner radius to SkeletonLoader --- lib/src/view_models/ui/skeleton_loader.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/src/view_models/ui/skeleton_loader.dart b/lib/src/view_models/ui/skeleton_loader.dart index c9ec31f1..a8851019 100644 --- a/lib/src/view_models/ui/skeleton_loader.dart +++ b/lib/src/view_models/ui/skeleton_loader.dart @@ -13,6 +13,8 @@ class SkeletonLoader extends StatefulWidget { final Color startColor; final Color endColor; final Duration duration; + final double cornerRadius; + const SkeletonLoader({ Key? key, required this.child, @@ -20,6 +22,7 @@ class SkeletonLoader extends StatefulWidget { this.duration = const Duration(seconds: 1), this.startColor = _veryLightGrey, this.endColor = _lightGrey, + this.cornerRadius = 15.0, }) : super(key: key); @override @@ -110,7 +113,8 @@ class SkeletonLoaderState extends State ]).createShader(rect); }, child: CustomPaint( - foregroundPainter: RectangleFillPainter(), + foregroundPainter: RectangleFillPainter( + cornerRadius: widget.cornerRadius), child: widget.child, ), ), @@ -129,12 +133,16 @@ class SkeletonLoaderState extends State class RectangleFillPainter extends CustomPainter { bool hasPainted = true; + final double cornerRadius; + + RectangleFillPainter({required this.cornerRadius}); + @override void paint(Canvas canvas, Size size) { canvas.drawRRect( RRect.fromRectAndRadius( Rect.fromLTWH(0, 0, size.width, size.height), - const Radius.circular(15.0), + Radius.circular(cornerRadius), ), Paint()..color = Colors.grey); }