import 'package:dio/dio.dart'; import 'package:labs/data/mapper/CharacterDataDtoModel.dart'; import 'package:pretty_dio_logger/pretty_dio_logger.dart'; import '../data/dtos/characters_dto.dart'; import '../domain/models/Student.dart'; import 'api_interface.dart'; class PotterRepo extends ApiInterface{ static final Dio _dio = Dio() ..interceptors.add(PrettyDioLogger( requestHeader: true, requestBody: true, )); static const String _baseUrl = 'https://api.potterdb.com'; @override Future?> loadData(String? q) async { const String url = '$_baseUrl/v1/characters'; final Response response = await _dio.get>(url, queryParameters: q != null ? {'filter[name_cont]': q} : null,); final CharactersDto dto = CharactersDto.fromJson(response.data as Map); final List? data = dto.data?.map((e) => e.toDomain()).toList(); return data; } }