title: Flutter: Update icon widget based on whether a document exists in Cloud Firestore
body: <p>I am designing an app to survey users on Current Affairs. I want a specific icon to appear based on whether the user has taken the Current Affairs survey or not. </p>
  
  <p>At the moment, I have a future which pulls the name of the current survey from Firestore, and then checks whether a document exists within the collection <em>_entrants</em>. If the user has taken the survey, it will be stored in a document with a document name of their user id (which is gotten from Firebase Authentication). </p>
  
  <p>If it does, the icon should be a tick icon, because the user has taken the survey. If they haven't taken the survey, the document will not exist and the user will see a another icon(like a 'New' icon), to show there's a new survey.</p>
  
  <p>I have used the following code to do get the information on whether the user has taken the survey: </p>
  
  <pre><code>Future&lt;void&gt; takenSurvey2() async {
  final sn = await Firestore.instance
      .collection('Controller')
      .document('Current Survey')
      .get();
  surveyName = sn['cs'];
    //The above gives me the name of the current survey
  final snapShot = await Firestore.instance
      .collection('$surveyName' + '_entrants')
      .document(userid)
      .get();
  if (snapShot.exists) {
    takenSurvey = true;
  } else {
    takenSurvey = false;
  }
  setState(() {});
  </code></pre>
  
  <p>}</p>
  
  <p>And then this is where the icon would be showed: </p>
  
  <pre><code>Positioned(
    right: 30,
    top: 20,
    child: FutureBuilder(
      future: takenSurvey2(),
      builder: (context, snapshot) {
        if (takenSurvey == false) {
          return Icon(
            Foundation.burst_new,
            size: 48,
            color: Color(0xff303841),
          );
        } else if (takenSurvey == true) {
          return Icon(
            Foundation.check,
            size: 48,
            color: Color(0xff303841),
          );
        } else
          return Container();
      })),
  </code></pre>
  
  <p>At the moment, this works just fine. **However, when I add in an AdMob advert the ad does not get a chance to load because <code>setState(() {})</code> within <code>takenSurvey2</code> seems to be rebuilding the app constantly, and I just see a flickering box.</p>
  
  <p>How could I go about getting an update from Cloud Firestore about whether a user has taken the survey and if the value changes (i.e. they take the survey, or I change the current survey) the page is rebuilt or the icons change, rather than my current set up of constantly rebuilding the page with <code>setstate</code>.</p>
  
  <p>Thank you. Sorry if this is not clear. I'm very new to coding. </p>