Check image is loaded in Image.network widget in flutter

后端 未结 5 722
忘了有多久
忘了有多久 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:50

    for this kind of issues it's good to use the cached_network_image so you can provide a placeholder when the image is loading and an error widget in case a resource fails to load

    String url = "http://via.placeholder.com/350x150";
    CachedNetworkImage(
           imageUrl: url,
           placeholder: (context,url) => CircularProgressIndicator(),
           errorWidget: (context,url,error) => new Icon(Icons.error),
         ),
    

提交回复
热议问题