Add progress bar in flutter when open pdf file from url
I have an app with the same feature, I used Dio this package supports downloading a file to your phone.
All you need to do is
Dio dio = Dio(); dio.download("*YOUR URL WHERE YOU WANT TO DOWNLOAD A FILE*", "*YOUR DESTINATION PATH*", onReceiveProgress: (rec, total) { print("Downloading " + ((rec / total) * 100).toStringAsFixed(0) + "%"); });
Never used this for pdf, but I've tried it for NetworkImage().Not sure if it'll help. But you can just try it if there's a way to use loadingBuilder in your code.
Image.network( imageUrl, fit: BoxFit.cover, loadingBuilder: (BuildContext context, Widget child, ImageChunkEvent loadingProgress) { if (loadingProgress == null) return child; else { return Center( child: CircularProgressIndicator( value: loadingProgress.expectedTotalBytes != null ? loadingProgress.cumulativeBytesLoaded / loadingProgress.expectedTotalBytes : null, ), ); } },);
u can use flutter_cached_pdfview
and this an example to view a pdf from URL and cache it with placeholder
u can replace placeholder with any widget like CircularProgressIndicator
PDF().cachedFromUrl( 'http://africau.edu/images/default/sample.pdf', placeholder: (progress) => Center(child: Text('$progress %')) )
take a look https://pub.dev/packages/flutter_cached_pdfview