1

I want to show a determinate progress indicator to my api network call.

I have seen other solutions where they hardcode the time like 2 seconds. But, i need the progress indicator to start when the call is made and finish at 100% when we have got the response. As you may know that time can vary.

  @override
  void initState() {
    super.initState();
    bloc.fetchAllBusiness();
  }

  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
        stream: bloc.allBusinesses,
        builder: (context, AsyncSnapshot<List<BusinessModel>> snapshot) 
        {
          if (snapshot.hasData) {
            return buildList(snapshot);
          } else if (snapshot.hasError) {
            //error handling
          }
          //This is where i need show a determinate indicator
          return Center(child: LinearProgressIndicator(value:"???"));
        }

I need to know, how to set the double here "???" which increases overtime and reaches 1.0 when the network call get its response.

Ali
  • 166
  • 1
  • 8
  • First you'd need some way to determine how many bytes you expect to receive, and then you need to keep track of many bytes you've received so far. – jamesdlin Sep 05 '19 at 15:23
  • Possible duplicate of [Flutter: How to get upload / download progress for http requests](https://stackoverflow.com/questions/50455131/flutter-how-to-get-upload-download-progress-for-http-requests) – Richard Heap Sep 06 '19 at 12:46

0 Answers0