title: How to set or remove map markers in dart/flutter
body: <p>I'm trying to place and remove markers on a map widget based on the user's 'active' status in Firebase:</p>
  <pre><code>Map &lt;MarkerId, Marker&gt; markers = &lt;MarkerId, Marker&gt;{};
  .
  .
  .
  markerStream.listen((List&lt;DocumentSnapshot&gt; documentList) {
  
    documentList.forEach((DocumentSnapshot document) {
  
      bool activeField = (document.data() as dynamic)['active'];   
      final GeoPoint point = (document
          .data() as dynamic)['position']['geopoint'];
      final uid = (document.data() as dynamic)['uid'].toString();
  
      //if field 'active' in firebase is set to true or false
  
      activeField == true ? _addMarker(point.latitude, point.longitude, uid) 
      :  _removeMarker(uid);
     });
  }
  </code></pre>
  <p>remove method:</p>
  <pre><code>_removeMarker( String uid) {
      
  // checks uid is in markers.values map, if there, remove from collection , if not, 
  //I need a way to put continue or ignore in the `orElse` parameter instead of null, because the markerId cannot be null:
  
      Marker? _markers = markers.values.firstWhere(
                (thisMarker) =&gt; thisMarker.markerId.value == uid ,
                orElse: () =&gt; null);
  
      setState(() {
        markers.remove(_marker);
      });
        }
  </code></pre>
  <p>This code runs when I omit the orElse parameter. markers will appear if all entries in firebase is set to true at runtime, and can goes away when switched to false. Problem is when the entries are already in 'false' before running, causes a Bad Element error because its still not stored in the collection. Or switching back to false from true will not remove marker from the map widget.</p>