Check image is loaded in Image.network widget in flutter

后端 未结 5 710
忘了有多久
忘了有多久 2021-02-04 05:54

I am new to Flutter. I try to load network image using image.network widget. it\'s work fine but sometimes it\'s take time to load.I added tap listener to ima

5条回答
  •  生来不讨喜
    2021-02-04 06:42

    You may use the loadingBuilder which is inbuilt feature from flutter for Image.Network

    I did it as below:

    Image.network(imageURL,fit: BoxFit.cover,
      loadingBuilder:(BuildContext context, Widget child,ImageChunkEvent loadingProgress) {
      if (loadingProgress == null) return child;
        return Center(
          child: CircularProgressIndicator(
          value: loadingProgress.expectedTotalBytes != null ? 
                 loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes
                 : null,
          ),
        );
      },
    ),
    

提交回复
热议问题