title: How to show RefreshIndicator intially while waiting data from backend API?
body: <p>So, I have this "Notifications" screen that displays notifications for the user. When navigating to this screen, it's going to be blank, since the notifications are being loaded live from a backend API.</p>
  
  <p>Here's some code to illustrate the problem:</p>
  
  <pre><code>class _MyItemsPageState extends State&lt;MyItemsPage&gt; {
    final GlobalKey&lt;RefreshIndicatorState&gt; _refreshIndicatorKey =
        new GlobalKey&lt;RefreshIndicatorState&gt;();
    List&lt;MyItem&gt; _items = [];
  
    @override
    void initState() {
      super.initState();
  
      // Nothing is displaying on screen initially, since the items are loaded from API on startup.
      // Preferably in this state, the refresh indicator would be shown while the items load.
      // It's not currently possible in this place, since it seems that the Widget hasn't been built yet.
  
      _refreshIndicatorKey.currentState.show(); // currentState null at this time, so the app crashes.
      _loadItems();
    }
  
    // (unrelated code removed)
  
    @override
    Widget build(BuildContext context) {
      return new Scaffold(
        appBar: new AppBar(
          title: new Text(widget.title),
        ),
        body: new RefreshIndicator(
          key: _refreshIndicatorKey,
          onRefresh: _loadItems,
          child: new ListView(
            padding: new EdgeInsets.symmetric(vertical: 8.0),
            children: _buildItemWidgets(),
          ),
        ),
      );
    }
  }
  </code></pre>
  
  <p>The problem is that the <strong>_refreshIndicator.currentState</strong> is null when the <strong>initState()</strong> function is called, since the Widget hasn't been built yet.</p>
  
  <p>What is the proper place of calling <strong>show()</strong> on the RefreshIndicator in this case?</p>