Untitled

mail@pastecode.io avatar
unknown
dart
a year ago
1.0 kB
1
Indexable
Never
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';

class CustomShimmerEffect extends StatelessWidget {
  final double width;
  final double height;
  final ShapeBorder? shapeBorder;

  CustomShimmerEffect.rectangular(
      {this.width = double.infinity, required this.height})
      : this.shapeBorder =
            RoundedRectangleBorder(borderRadius: BorderRadius.circular(10.0));

  CustomShimmerEffect.circular(
      {this.width = double.infinity,
      required this.height,
      this.shapeBorder = const CircleBorder()});

  @override
  Widget build(BuildContext context) => Shimmer.fromColors(
        baseColor: Colors.grey[200]!,
        highlightColor: Colors.grey[300]!,
        period: const Duration(seconds: 2),
        child: Container(
          width: width,
          height: height,
          padding: const EdgeInsets.all(10.0),
          decoration: ShapeDecoration(
            color: Colors.grey[400],
            shape: shapeBorder!,
          ),
        ),
      );
}