I am using shimmer package for creating a loading page. This is how it looks:
I want to create the shimmer boxes like this:
My code:
class _Shimmer extends StatelessWidget {
const _Shimmer();
@override
Widget build(BuildContext context) {
return Shimmer.fromColors(
baseColor: Colors.grey.shade300,
highlightColor: Colors.grey.shade100,
enabled: true,
child: SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.max,
children: [
const SizedBox(height: 40),
...List.generate(
10,
(index) => const Column(
children: [
_CardPlaceHolder(),
SizedBox(height: 16),
],
),
),
],
),
),
);
}
}
class _CardPlaceHolder extends StatelessWidget {
const _CardPlaceHolder({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Stack(
children: [
Container(
width: double.infinity,
height: 86,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(18.0),
color: Colors.white,
),
),
],
);
}
}
When I add another container as the main container's child, it doesn't shown. Is there a way to create this with the package or should I create a new shimmer widget?
Picked this from the Shimmer package's example folder and modified it a little. You can replace your _CardPlaceHolder code with this