Aditya Patil
Aditya Patil

Reputation: 1486

How to show loader while loading image using file path in flutter?

How to show loader before loading complete image from file? Before loading image in Imageview it takes some time before image is visible to user.

Image.file(
  File(selectedImagePath),
  width: double.infinity,
  height: double.infinity,
 ),

Upvotes: 0

Views: 1407

Answers (1)

Aditya Patil
Aditya Patil

Reputation: 1486

As suggested by @pskink You can use Image constructor

Image(
      image: FileImage(
      File(selectedImagePath)),
         width: double.infinity,
         height: double.infinity,
         loadingBuilder:
             (context, child, loadingProgress) {
             if (loadingProgress == null) {
                 debugPrint('image loading null');
                 return child;
             }
             debugPrint('image loading...');
             return const Center(
             child: CircularProgressIndicator());
          },
       ),

Upvotes: 1

Related Questions