notifyListeners not called inside async function

186 views Asked by At

I have the following code where I call notifyListeners. The first function works as expected but the fetch function never calls the notifyListeners.

 void toggleMapType() {
    this.mapType = this.mapType == MapType.normal ? MapType.satellite : MapType.normal; 
    notifyListeners(); 
  }

    Future<void> fetchPlacesByKeywordAndPosition(String keyword, double latitude, double longitude) async {

      final result = await Webservice().fetchPlacesByKeywordAndPosition(keyword, latitude, longitude); 
      this.places = result.map((place) => PlaceViewModel(place)).toList(); 
      notifyListeners(); 
  }
0

There are 0 answers