getUserSuggestions method
Implementation
Future<List<OrderData>> getUserSuggestions(String query) async {
var request = {
'api_key': await Constants.apiKey(),
'merchant_id': Storage.getValue(Constants.merchantID)
};
final url = Uri.parse('${await Constants.baseUrl()}/merchant/orders/get');
final response = await http.post(url, body: request);
if (response.statusCode == 200) {
var jsonString = response.body;
AllOrdersResponse allContestants =
AllOrdersResponse.fromJson(json.decode(jsonString));
orderList.clear();
orderList.addAll(allContestants.data!.obs);
return orderList.where((user) {
final nameLower = user.products![0].name!.toLowerCase();
final queryLower = query.toLowerCase();
return nameLower.contains(queryLower);
}).toList();
} else {
throw Exception();
}
}