getAvailabilityModel method
Future<String>
getAvailabilityModel(
- Datum content,
- SharedPreferences sharedPreferences
)
Implementation
Future<String> getAvailabilityModel(
contentmodel.Datum content, SharedPreferences sharedPreferences) async {
String availabilityData =
sharedPreferences.getString(DeviceStorage.availabilityData) ?? "";
if (availabilityData.isEmpty) {
availabilityData = await initializeAvailability();
}
var availabilityJSON = jsonDecode(availabilityData);
AvailabilityModel availabilityModel =
AvailabilityModel.fromMap(availabilityJSON);
List<Datum> availabilitySet = availabilityModel.data!;
String model = "";
String availabilityID = content.contentdetails!.length == 1
? content.contentdetails![0].availabilityset![0].toString()
: content.contentdetails![1].availabilityset![0].toString();
for (var i = 0; i < availabilitySet.length; i++) {
Datum availability = availabilitySet[i];
String availabilityInModel = availability.availabilityid!;
if (availabilityInModel == availabilityID) {
model = availability.pricemodel!;
break;
}
}
return model;
}