title: Flutter - How to give progress bar to on:Pressed() function of a button?
body: <p>I am fetching data from <em>firebase database</em> in a <em>async</em> function which triggers when the button is pressed. When the data fetching is complete it moves to the next page(next acitivty). So, in this whole process the async on pressed function takes time to execute the whole code. So, i wanted to show a progress bar until the whole code is executed. Can anyone suggest me how can i show a progress bar until the new activity starts.</p>
  <p>Here is my code:</p>
  <pre><code>FlatButton(
  
                child: Text(&quot;Next&quot;,style: TextStyle(
                color: Colors.white,
                    fontWeight: FontWeight.bold,
                    fontFamily: &quot;Calibri&quot;,
                    fontSize: 20)),
                color: Colors.blue,
                onPressed:() {
                  elist.then((value)
               async {
  
  
  
                   for (var item in value) {
                     alleyes.add(new facial(criminal_id: item.criminal_id,
                         part_size: item.part_size,
                         link: item.link));
                     Uint8List bytes = (await NetworkAssetBundle(Uri.parse(item.link)).load(item.link)).buffer.asUint8List();
                     eye_str.add(String.fromCharCodes(bytes));
  
  
  
  
                   }
                   Navigator.push(context,
                       MaterialPageRoute(builder: (context)=&gt;App()));
               }
                  );
                },
              )
  
  </code></pre>