title: How to update state from static method in Flutter?
body: <p>I have a bottom nav bar that uses this code to switch widgets:</p>
  
  <pre><code>    void _onItemTapped(int index) {
      setState(() {
        selectedIndexGlobal = index;
        print(index);
      });
    }
  </code></pre>
  
  <p>And shows the needed widgets in body:</p>
  
  <pre><code>body: SafeArea(
      child: new LayoutBuilder(
            builder: (BuildContext context, BoxConstraints constraints) {
              Container con = Container(
                  child: _widgetOptions.elementAt(selectedIndexGlobal)
              );
              return con;
            }
        ))
  </code></pre>
  
  <p>I also have a GridView with static children list loaded from Firebase, and tried to apply a GestureDetector to it, to change selectedIndex and update screen state:</p>
  
  <pre><code>static getExpenseItems(AsyncSnapshot&lt;QuerySnapshot&gt; snapshot, BuildContext context) {
      try {
        snapshot.data.documents.sort((a, b) =&gt;
            a.data["order"].compareTo(b.data["order"]));
      } on NoSuchMethodError {}
  
      return snapshot.data.documents
          .map((doc) =&gt;
      new GestureDetector(
          behavior: HitTestBehavior.translucent,
          onTap: () {
          catName = doc["catName"];
          setState(() {
            selectedIndexGlobal = 4;
          });
          },
          child: new Container(
              child: Container(
                      padding: EdgeInsets.only(top: 15, left: 10, bottom: 15),
                      decoration: new BoxDecoration(
                          border: new Border.all(color: Colors.grey[200],
                          width: 0.8)),
                      child: Align(
                        alignment: Alignment.centerLeft,
                        child: Text(doc["name"],
                            style: TextStyle(fontSize: categoriesFont),
                            textAlign: TextAlign.center),
                      )
                  )
          )
  
      )
      ).toList();
    }
  </code></pre>
  
  <p>But setState can't be called from a static method, as well as GridView.count doesn't let me use non-static widgets as child. What should I do then to update state on click?</p>