Search From 5 (1)

This commit is contained in:
Serxiolog 2024-11-18 16:32:11 +04:00
parent 65217136a8
commit e52ab22a31

View File

@ -16,12 +16,16 @@ class AnimeRepository extends ApiInterface {
static const String _baseUrl = 'https://api.jikan.moe';
@override
Future<List<CardData>?> loadData() async{
Future<List<CardData>?> loadData({String? q}) async{
try
{
const String url = '$_baseUrl/v4/anime';
final Response<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(url);
Map<String, dynamic> query = {'limit' : 5, 'q' : q};
final Response<dynamic> response =
await _dio.get<Map<dynamic, dynamic>>(
url,
queryParameters: query,
);
final AnimesDto dto = AnimesDto.fromJson(response.data as Map<String, dynamic>);
final List<CardData>? data = dto.data?.map((e) => e.toDomain()).toList();
return data;