initializeAvailability method

Future<String> initializeAvailability()

Implementation

Future<String> initializeAvailability() async {
  SharedPreferences sharedPreferences = await DeviceStorage().getInstance();
  String savedAvailability =
      sharedPreferences.getString(DeviceStorage.availabilityData) ?? "";
  if (savedAvailability.isNotEmpty) {
    return savedAvailability;
  }
  AvailabilityModel data = await NetworkHandler.fetchAvailability();
  String dataString = jsonEncode(data.toMap());
  sharedPreferences.setString(DeviceStorage.availabilityData, dataString);
  return dataString;
}