title: Flutter : How to show Progress indicator until the data is fetched from the server
body: <p>I want to show a progress indicator until the required data is fetched from the server. Currently what I am doing is made a function getQuotes() that will fetch the data into a variable using setState(). And the Used the FutureBuilder where its future parameter is set to getQuotes(). But this approach gives me a non-ending CircularProgressIndicator. I don't why it is happening. Is ther any problem with the combination of FutureBuilder() and setState() ? Can Some one help ?</p>
  <p>Here is my code,</p>
  <pre><code>Map&lt;String, dynamic&gt; userInfo = {};
  
    Future&lt;void&gt; getQoutes() async {
      var data = await FirebaseFirestore.instance.collection('user').doc(auth.currentUser!.uid).get();
      setState(() {
        userInfo = data.data() as Map&lt;String, dynamic&gt;;
      });
    }
  
  @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(
            'Some Quotes',
          ),
          backgroundColor: Colors.deepOrange,
        ),
        body: FutureBuilder (
          future: getQoutes(),
          builder: (BuildContext context, AsyncSnapshot snapshot) {
            switch (snapshot.connectionState) {
              case ConnectionState.done:
                if (snapshot.hasError) {
                  return Text('Error : ${snapshot.error}');
                }
                return SingleChildScrollView(
                  child: Container(
                  height: MediaQuery.of(context).size.height,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Expanded(
                          child: ListView.builder(
                            itemCount: 3,
                            scrollDirection: Axis.vertical,
                            itemBuilder: (context, index) {
                            return Card_fun(userInfo['quotes'][index]);
                            }
                          )
                        )
                      ],
                    ),
                  )
                );
              default:
                return const CircularProgressIndicator();
            }
          }
        ),
      );
    }
  </code></pre>