asSkeleton method

Widget asSkeleton({
  1. bool enabled = true,
  2. bool leaf = false,
  3. Widget? replacement,
  4. bool unite = false,
  5. AsyncSnapshot? snapshot,
})

Implementation

Widget asSkeleton(
    {bool enabled = true,
    bool leaf = false,
    Widget? replacement,
    bool unite = false,
    AsyncSnapshot? snapshot}) {
  if (snapshot != null) {
    enabled = !snapshot.hasData;
  }
  if (this is Avatar || this is Image) {
    // https://github.com/Milad-Akarie/skeletonizer/issues/17
    return Skeleton.leaf(
      enabled: enabled,
      child: this,
    );
  }
  if (unite) {
    return Skeleton.unite(
      unite: enabled,
      child: this,
    );
  }
  if (replacement != null) {
    return Skeleton.replace(
      replace: enabled,
      child: replacement,
    );
  }
  if (leaf) {
    return Skeleton.leaf(
      enabled: enabled,
      child: this,
    );
  }
  return Skeletonizer(
    enabled: enabled,
    child: this,
  );
}