title: Flutter: Why setState(( ) { }) set data again and again
body: <p>I use <code>setState(() {})</code> for assigning a value to a variable. But it's printing again and again. Why does it react like this? And how can I fix it?</p>
  <p>Here is my code:</p>
  <pre><code>class Sample extends StatefulWidget {
    @override
    _SampleState createState() =&gt; _SampleState();
  }
  
  class _SampleState extends State&lt;Sample&gt; {
    String _message;
    String _appLink;
    Firestore db = Firestore.instance;
    @override
    Widget build(BuildContext context) {
      db.collection('share').document('0').get().then((value) {
        var message = value.data['message'];
        print(message);
        var appLink = value.data['appLink'];
        setState(() {
          _message = message;
          _appLink = appLink;
        });
      });
      return Container(
        child: Text('$_message $_appLink'),
      );
    }
  }
  </code></pre>
  <blockquote>
  <p>Here is my Output:</p>
  </blockquote>
  <p>Here <code>_appLink</code> value is <code>www.facebook.com</code></p>
  <p><a href="https://i.stack.imgur.com/nmNpN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmNpN.jpg" alt="enter image description here" /></a></p>