getVenues method

dynamic getVenues()

retrieves the list of venues from the storage location specified by venueLatLngKey

Implementation

getVenues() async {
  venues = Queue<VenueLatLng>(); // reset

  try {
    var atKey = AtKey()
      ..metadata = Metadata()
      ..metadata.ttr = -1
      ..metadata.ccd = true
      ..key = venueLatLngKey;
    var value = await AtClientManager.getInstance()
        .atClient
        .get(atKey)
        .catchError((e) async {
      await _storeVenue(Queue<VenueLatLng>());
      return AtValue();
    });

    // ignore: unnecessary_null_comparison
    if (value != null && value.value != null) {
      var _res = jsonDecode(value.value);
      Queue<VenueLatLng> _tempVenues = Queue<VenueLatLng>();
      _res['venues'].forEach((e) {
        _tempVenues.add(VenueLatLng.fromJson(e));
      });
      venues = _tempVenues;
    }
  } catch (e) {
    _logger.severe('Error in getVenues $e');
  }
}