Skip to content

Instantly share code, notes, and snippets.

@jtmuller5
Created July 23, 2025 16:52
Show Gist options
  • Select an option

  • Save jtmuller5/37b8e0d71cb2f64f8bb5ed0f914503b1 to your computer and use it in GitHub Desktop.

Select an option

Save jtmuller5/37b8e0d71cb2f64f8bb5ed0f914503b1 to your computer and use it in GitHub Desktop.
Flutter loading widget that shows a simple skeleton animation on a custom-sized box
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
class SkeletonBox extends StatelessWidget {
const SkeletonBox({
super.key,
required this.width,
required this.height,
this.borderRadius = 4.0,
this.delay,
});
final double width;
final double height;
final double borderRadius;
final Duration? delay;
@override
Widget build(BuildContext context) {
return Container(
width: width,
height: height,
decoration: BoxDecoration(
color: Colors.grey[300],
borderRadius: BorderRadius.circular(borderRadius),
),
).animate(onPlay: (controller) => controller.repeat(reverse: true)).shimmer(
duration: 1500.ms,
color: Colors.grey[100]!,
delay: delay ?? 0.ms,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment