GithubHelp home page GithubHelp logo

fancy-shimmer-image's Introduction

Buy Me A Coffee

Introduction

Package created for the purpose of uploading images from the internet, giving the possibility of showing a beautiful Shimmer animation while the images are not loading. And it is still possible to create a widget to be shown in case the image upload fails for some reason.

This package is basically a union of two known packages:

Basic Usage

You can use the package on the fly by simple passing a URL of an image to the FancyShimmerImage widget.

FancyShimmerImage(  
  imageUrl: 'https://images.unsplash.com/photo-1465572089651-8fde36c892dd?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80',  
),

That will produce a image that's is cacheable by default and that has a default (grey) Shimmer animation. Similar to result below:

enter image description here

More Advanced Usage

If you don't like the default widget behavior, you can set the background colors of the image, the color of the shimmer base effect, and the color of the highlighted effect.

FancyShimmerImage(  
  imageUrl: 'https://static.businessinsider.sg/2018/12/12/5c1c90f8e04d6243c7019cf6.png',  
  shimmerBaseColor: randomColor(),  
  shimmerHighlightColor: randomColor(),  
  shimmerBackColor: randomColor(),  
)

By randomizing the colors you can have a result similar to this:

enter image description here

Other thing you can do is to configure the direction of the Shimmer and it's speed. In the above example i configured it to have top to bottom direction and 300 milliseconds of speed.

enter image description here

One last step you can configure is to configure the widget that will appear in case the image upload fails for some reason. In this case just pass the desired widget in the errorWidget parameter. If no value is passed, a default error widget will be used.

FancyShimmerImage(  
  imageUrl: 'https://static.businessinsider.sg/2018/12/12/5c1c90f8e04d6243c7019cf6.png',  
  errorWidget: Image.network('https://i0.wp.com/www.dobitaobyte.com.br/wp-content/uploads/2016/02/no_image.png?ssl=1'),
)

enter image description here

fancy-shimmer-image's People

Contributors

masayukiyama avatar rodrigobastosv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

fancy-shimmer-image's Issues

Cannot make shimmer shape circular

Tried using:
BoxDecoration & CircularAvtar

    Container(
      decoration: BoxDecoration(shape: BoxShape.circle),
      margin: EdgeInsets.all(12.0),
      child: FancyShimmerImage(
        imageUrl: business[index].imgUrl,
        height: 90.0,
        width: 90.0,
        boxFit: BoxFit.fitHeight,
      ),
    );

and almost all ways to make the widget circular but still cannot make shimmer circular.

Image not showing up

Hi,

I tried the example code and the shimmer works, but no image is displayed. I tried different image urls and still can't make it show up. Am I missing anything?

Thanks!

[Feature Request]: Need a FancyImageProvider to add a photo to the container decorator

There are often times when you need to display some widget on top of an image, sometimes the only option is to use Stack, but Stack requires more computing resources to render widgets. It requires more than if we use a child-parent widget tree.

Therefore, in order to display an image, and it was not the final one in the widget tree, they often add the image to the container decorator, and in the child element of the container the necessary widgets are defined to be displayed on top of the image.

The package cached_network_image, which the fancy_shimmer_image package depends on, contains a CachedNetworkImageProvider, and I assume that it is possible to add a shimmer effect for the FancyImageProvider

Getting error on image loading.

Error

E/SQLiteLog(19645): (1032) statement aborts at 12: [INSERT INTO cacheObject (url, key, relativePath, eTag, validTill, touched, length) VALUES (?, ?, ?, ?, ?, ?, ?)] attempt to write a readonly database

My code

FancyShimmerImage(
                    imageUrl: '$imgProfile',
                    errorWidget: Icon(
                      Icons.account_circle_rounded,
                      size: 100,
                      color: primaryVariant,
                    ),
                    boxFit: BoxFit.cover,
                  ),

[Deprecated Version] : fancy_shimmer_image >=2.0.0 is forbidden for shimmer: ^3.0.0

Hy @rodrigobastosv,

When I was using this package I faced this issue saying the current version is deprecated, it seems like the newest version of Shimmer is ^3.0.0, and you are using ^2.0.0.

Because fancy_shimmer_image >=2.0.0 depends on shimmer ^2.0.0 and <project-name> depends on shimmer ^3.0.0, fancy_shimmer_image >=2.0.0 is forbidden.
So, because <project-name> depends on fancy_shimmer_image ^2.0.2, version solving failed.
pub get failed
command: "/home/sujith/flutter/bin/cache/dart-sdk/bin/dart __deprecated_pub --directory . get --example"
pub env: {
  "FLUTTER_ROOT": "/home/sujith/flutter",
  "PUB_ENVIRONMENT": "flutter_cli:get",
  "PUB_CACHE": "/home/sujith/.pub-cache",
}
exit code: 1

I can also help by contributing to this issue for fixing it...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.