Skip to content

Commit

Permalink
fix: adds corner radius to SkeletonLoader
Browse files Browse the repository at this point in the history
  • Loading branch information
FilledStacks committed Jun 24, 2024
1 parent 9f88465 commit 1b2c51f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/src/view_models/ui/skeleton_loader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ class SkeletonLoader extends StatefulWidget {
final Color startColor;
final Color endColor;
final Duration duration;
final double cornerRadius;

const SkeletonLoader({
Key? key,
required this.child,
required this.loading,
this.duration = const Duration(seconds: 1),
this.startColor = _veryLightGrey,
this.endColor = _lightGrey,
this.cornerRadius = 15.0,
}) : super(key: key);

@override
Expand Down Expand Up @@ -110,7 +113,8 @@ class SkeletonLoaderState extends State<SkeletonLoader>
]).createShader(rect);
},
child: CustomPaint(
foregroundPainter: RectangleFillPainter(),
foregroundPainter: RectangleFillPainter(
cornerRadius: widget.cornerRadius),
child: widget.child,
),
),
Expand All @@ -129,12 +133,16 @@ class SkeletonLoaderState extends State<SkeletonLoader>

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);
}
Expand Down

0 comments on commit 1b2c51f

Please sign in to comment.