getKuralsByEnglishSectionNames method
Future
getKuralsByEnglishSectionNames(
{ - required String sectionName,
})
Implementation
Future getKuralsByEnglishSectionNames({required String sectionName}) async {
isAllEnglishSectionKuralsLoaded = false;
englishSectionNameKuralsList.clear();
englishSectionNameKuralsErrorMessage = '';
try {
ApiResponse response = await ApiServices.get(
requestHeaders: {},
requestParams: {'englishSectionName': sectionName},
endpoint: UrlServices.getKuralsByEnglishSectionName,
);
debugPrint(response.toJson().toString());
if (response.status != null && response.status!) {
List<dynamic> responseList = response.response ?? [];
englishSectionNameKuralsList =
responseList.map((e) => Kural.fromJson(e)).toList();
isAllEnglishSectionKuralsLoaded = true;
} else {
englishSectionNameKuralsErrorMessage =
response.message ?? 'Server error, failed to load kurals.';
}
} catch (e, stackTrace) {
debugPrint('Error while fetching english section kurals: $e, $stackTrace');
englishSectionNameKuralsErrorMessage = 'Error while fetching kurals: $e';
}
notifyListeners();
}