skip to Main Content

I am trying to display a file on tap of button. But before the file loads, I want the circular progress indicator to start and after the file loads, I want it to stop. I have implemented the following code but the problem is the indicator keeps on loading even after file loads.

  InkWell(

    onTap: () async {
      player.stop();



         Center(
                  child: CircularProgressIndicator(),
                );

      final files = await loadPdfFromNetwork(file.url);
      openPdf(context, files, file.url,file.name.split('.').first);



    }

2

Answers


  1. You could use Navigator.of(context).pop .

    InkWell(

    onTap: () async {
      player.stop();
    
    
    
         Center(
                  child: CircularProgressIndicator(),
                );
    
      final files = await loadPdfFromNetwork(file.url);
      openPdf(context, files, file.url,file.name.split('.').first);
    

    Navigator.of(context).pop

    }
    
    Login or Signup to reply.
  2. You can use stream builder to avoid any error in future as well.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search