title: How do I make RefreshIndicator disappear?
body: <p>I have this code that has the parent widget <code>Homepage</code> and the child widget <code>CountryList</code>. In <code>CountryList</code>, I have created a function that uses an API to get a list of countries. I felt like enabling a <code>RefreshIndicator</code> in the app, so I had to modify the <code>Homepage</code> widget and add <code>GlobalKey</code> to access <code>getCountryData()</code> function of <code>CountryList</code> widget. The <code>RefreshIndicator</code> has done its job well. But the problem now is that when I pull and use the <code>RefreshIndicator</code> in the app, the <code>getCountryData()</code> function is called, but even after showing all data in the list, the circular spinner doesn't go (shown in the screenshot).<a href="https://i.stack.imgur.com/YddiG.png" rel="noreferrer"><img src="https://i.stack.imgur.com/YddiG.png" alt="App Screenshot"></a></p>
  
  <p>So, could anyone please suggest me a way to make the spinner go?
  The code of <code>main.dart</code> containing <code>Homepage</code> widget is given below:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'country_list.dart';
  GlobalKey&lt;dynamic&gt; globalKey = GlobalKey();
  
  void main() =&gt; runApp(MaterialApp(home: Homepage()));
  
  class Homepage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(title: Text("List of countries"), actions: &lt;Widget&gt;[
          IconButton(icon: Icon(Icons.favorite), onPressed: (){},)
        ],),
        body: RefreshIndicator(child: CountryList(key:globalKey), onRefresh: (){globalKey.currentState.getCountryData();},),
      );
    }
  }
  </code></pre>
  
  <p>And the code of <code>country_list.dart</code> containing <code>CountryList</code> widget is:</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'dart:async';
  import 'package:http/http.dart' as http;
  import 'dart:convert';
  import 'package:flutter_svg/flutter_svg.dart';
  class CountryList extends StatefulWidget {
    CountryList({Key key}) : super(key: key);
    @override
    _CountryListState createState() =&gt; _CountryListState();
  }
  
  class _CountryListState extends State&lt;CountryList&gt; {
    List&lt;dynamic&gt; _countryData;
    bool _loading = false;
    @override
    void initState() {
      // TODO: implement initState
      super.initState();
      this.getCountryData();
    }
  
    Future&lt;String&gt; getCountryData() async {
      setState(() {
        _loading = true;
      });
      var response =
          await http.get(Uri.encodeFull("https://restcountries.eu/rest/v2/all"));
      var decodedResponse = json.decode(response.body);
      setState(() {
        _countryData = decodedResponse;
        _loading = false;
      });
    }
  
    @override
    Widget build(BuildContext context) {
      return _loading?Center(child: Column(mainAxisAlignment: MainAxisAlignment.center, children: &lt;Widget&gt;[CircularProgressIndicator(), Padding(padding: EdgeInsets.all(5.0),), Text("Loading data...", style: TextStyle(fontSize: 20.0),)],)):ListView.builder(
        itemCount: _countryData.length,
        itemBuilder: (BuildContext context, int index) {
          return Card(
            child: ListTile(
              leading: SvgPicture.network(_countryData[index]['flag'], width: 60.0,),
              title: Text(_countryData[index]['name']),
              trailing: IconButton(
                icon: Icon(Icons.favorite_border),
                onPressed: () {},
              ),
            ),
          );
        },
      );
    }
  }
  </code></pre>