hnvn / flutter_shimmer

A package provides an easy way to add shimmer effect in Flutter project
BSD 3-Clause "New" or "Revised" License
1.77k stars 200 forks source link

Added feature to hide the shimmer effect #32

Open gmaggio opened 3 years ago

gmaggio commented 3 years ago

This is practically the same request as https://github.com/hnvn/flutter_shimmer/pull/12. I think it will come in handy for a lot of developers to have the ability to remove all gradient blending and just draw the child. A simple use case is to have a Card UI that shimmers while loading and reveals the text content once loaded.

How to: Set hideOnDisabled to true to hide the shimmer effect when enabled is false.

The-Redhat commented 3 years ago

Looks good to me

gmaggio commented 3 years ago

@hnvn I wonder if you could review this and possibly merge it as I think it's a much needed feature. Cheers.

makinghappen commented 1 year ago

@hnvn can you please merge this?

krrskl commented 6 months ago

In case someone else comes to this topic and wants an alternative solution to waiting for the feature, they could create the logic in a widget and use that as a shimmer wrapper:

import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';

class CustomShimmer extends StatelessWidget {
  final Widget child;
  final bool loading;
  final Color baseColor;
  final Color highlightColor;

  const CustomShimmer({
    super.key,
    required this.child,
    this.loading = false,
    this.baseColor = Colors.white,
    this.highlightColor = Colors.white60,
  });

  @override
  Widget build(BuildContext context) {
    if (loading) {
      return Shimmer.fromColors(
        baseColor: baseColor,
        highlightColor: highlightColor,
        child: child,
      );
    }

    return child;
  }
}