getAllPlaces static method

Future<Map<String, List<PlacesModel>>> getAllPlaces()

Gets the entire map of places.

Implementation

static Future<Map<String, List<PlacesModel>>> getAllPlaces() async {
  final String? encodedData = _prefs?.getString(_keyMap);
  if (encodedData != null) {
    final Map<String, dynamic> decodedData = jsonDecode(encodedData);
    return decodedData.map((key, value) {
      final List<dynamic> placesJson = jsonDecode(value);
      return MapEntry(
          key, placesJson.map((json) => PlacesModel.fromJson(json)).toList());
    });
  } else {
    return {};
  }
}