Search code examples
imageflutterfile

how to show CircularProgressIndicator while loading Image.file in flutter


This is how we show CircularProgressIndicator while loading image from the network (URL). Wonder how we can do something similar if the image File is local

CachedNetworkImage(
   placeholder: (context, url) => CircularProgressIndicator(),
   imageUrl:'https://www.yourdomain.com/xyz.png',
)

Solution

  • This should do the trick :

    return Container(
          child: FutureBuilder(
            future: Future.delayed(Duration(seconds: 3)),
            builder: (c, s) => s.connectionState == ConnectionState.done
                ? Image.asset("assets/aem.png")
                : CircularProgressIndicator(),
          ),
        );