searchPeople method

Future<BuiltList<Person>> searchPeople({
  1. String? query,
  2. String? orderBy,
  3. String? sort,
  4. int page = 1,
})

Implementation

Future<BuiltList<Person>> searchPeople(
    {String? query, String? orderBy, String? sort, int page = 1}) async {
  var url = '/people?page=$page';
  if (query != null) url += '&q=$query';
  if (orderBy != null) url += '&order_by=$orderBy';
  if (sort != null) url += '&sort=$sort';
  var response = await _getResponse(url);

  final results = response['data'] ?? [];
  return BuiltList(results.map((i) => Person.fromJson(i)));
}