getKuralsByTamilChapterNames method
Future
getKuralsByTamilChapterNames(
{ - required String chapterName,
})
Implementation
Future getKuralsByTamilChapterNames({required String chapterName}) async {
isAllTamilChaptersKuralsLoaded = false;
tamilChapterNameKuralsList.clear();
tamilChapterNameKuralsErrorMessage = '';
try {
ApiResponse response = await ApiServices.get(
requestHeaders: {},
requestParams: {'tamilChapterName': chapterName},
endpoint: UrlServices.getKuralsByTamilChapterName,
);
debugPrint(response.toJson().toString());
if (response.status != null && response.status!) {
List<dynamic> responseList = response.response ?? [];
tamilChapterNameKuralsList =
responseList.map((e) => Kural.fromJson(e)).toList();
isAllTamilChaptersKuralsLoaded = true;
} else {
tamilChapterNameKuralsErrorMessage = response.message ??
'Server error, failed to load tamil chapter kurals.';
}
} catch (e, stackTrace) {
debugPrint('Error while fetching tamil chapter kurals: $e, $stackTrace');
tamilChapterNameKuralsErrorMessage =
'Error while fetching tamil chapter kurals: $e';
}
notifyListeners();
}