getList method
Implementation
Future<List> getList(String path, {int page = 1, int limit = 20, bool isGetAll = true}) async {
dynamic resp;
List temp;
final List list = [];
Map<String, dynamic> json;
while (page > 0) {
resp = await getAPI2('${Constants().apiVersion}${path}page=$page&limit=$limit');
if (resp.isNotEmpty) {
json = jsonDecode(resp);
if (Util.checkKeyFromJson(json, 'success') && Util.checkKeyFromJson(json, 'data') && json['success']) {
temp = json['data'];
if (temp.isNotEmpty) list.addAll(temp);
if (isGetAll) temp.length == limit ? page++ : page = 0;
else page = 0;
}
} else page = 0;
}
return list;
}