getEventList function
Implementation
Future<EventListModel?> getEventList({bool showLoader = false, bool isFavourite = false, bool isSaveFilter = false, bool isFromReset = false}) async {
if (showLoader) appStore.setLoading(true);
try {
// if (isFromReset == true) {
// isSaveFilter = false;
// }
String filter = (isSaveFilter && !isFromReset) ? "&apply_filter=true" : '';
// String filter = isSaveFilter ? "&apply_filter=true" : '';
String sortEventValue = getStringAsync(SORT_EVENT_VALUE);
String sortEventKey = getStringAsync(SORT_EVENT_KEY);
// print("sortEventValue:$sortEventValue");
String sortKeyValuePair = (sortEventKey.isNotEmpty) ? "&$sortEventKey=$sortEventValue" : "";
String musicTypeId = ((appStore.selectedMusicId != -1) && (appStore.headerIndex != 2 && appStore.headerIndex != -1)) ? "&music_type_id=${appStore.selectedMusicId}" : '';
String userId = (appStore.userId != null && appStore.userId != 0) ? "?user_id=${appStore.userId}" : '?user_id=';
String type = isFavourite ? '&is_favourite=1' : '';
String latlang = (appStore.isLocationPermissionGranted && (appStore.headerIndex == 2)) ? "&latitude=${appStore.latitude}2&longitude=${appStore.longitude}" : "";
String perPage = "&per_page=All";
EventModel res = EventModel.fromMap(await (handleResponse(await buildHttpResponse("${APIEndPoint.eventList}$userId$type$latlang$musicTypeId$sortKeyValuePair$filter$perPage", method: HttpMethod.GET))));
cachedEventListModel = await res.data;
appStore.setLoading(false);
return await res.data;
} catch (e) {
appStore.setLoading(false);
throw errorSomethingWentWrong;
}
}