0

I have a case where I am using FutureBuilder and while loading I am showing my CircularProgressIndicator. Now I want to set a value to the loader but I don't have one and I don't really have any way of knowing how much time will it take to complete the future. My current code is something like this:

FutureBuilder(
  future: getSoilData(context),
  builder: (BuildContext context, snapshot) {
    if (snapshot.connectionState == ConnectionState.done) {
    return makeBody();
    }
    
    return LoadingBar();
  },
),

So how do I set the value to my progress bar so that the user gets an idea of how much more time the loader is going to take.

L.Goyal
  • 773
  • 2
  • 6
  • 23

1 Answers1

0

ConnectionState have wainting

if (snapshot.connectionState == ConnectionState.done) {
    return makeBody();
    }
else if (snapshot.connectionState == ConnectionState.waiting) {
    return LoadingBar();
  },

or you can just put an else

if (snapshot.connectionState == ConnectionState.done) {
    return makeBody();
    }
else {
    return LoadingBar();
  },
Ardeshir ojan
  • 1,914
  • 1
  • 13
  • 36
  • That's what I am currently doing right now. I want to add the value to the loading bar so that the user gets an idea of how much more time is it gonna take. – L.Goyal Oct 13 '21 at 06:55