title: How to use both FutureBuilder and setState method?(Flutter)
body: <p>I tried to load data from the database by using FutureBuilder like this code.</p>
  <pre><code>// counter application
  
  import 'package:flutter/material.dart';
  
  class SetStateScreen extends StatefulWidget {
    @override
    _SetStateScreenState createState() =&gt; _SetStateScreenState();
  }
  
  class _SetStateScreenState extends State&lt;SetStateScreen&gt; {
    Future&lt;int&gt; getData() async {
      int initNumFromDB = 0; // fetch some asynchronous initial value
      return initNumFromDB;
    }
  
    @override
    Widget build(BuildContext context) {
      int counter;
      return Container(
        color: Colors.white,
        child: FutureBuilder(
            future: getData(),
            builder: (BuildContext context, AsyncSnapshot&lt;int&gt; snapshot) {
              Widget childWidget;
              if (snapshot.hasData) {
                counter = snapshot.data; 
                childWidget = Center(
                  child: Container(
                      child: FlatButton(
                    onPressed: () {
                      setState(() {
                        counter += 1;
                      });
                    },
                    child: Text(&quot;$counter&quot;),
                  )),
                );
              } else {
                childWidget = Container();
              }
              return childWidget;
            }),
      );
    }
  }
  </code></pre>
  <p>But, when pushing the button and running the setState method, FutureBuilder loads initial data again and reset the counter number. How to load initial data once, and run this code correctly?</p>