import 'package:dio/dio.dart'; class ApiService { final Dio dio; ApiService({required String baseUrl}) : dio = Dio(BaseOptions( baseUrl: baseUrl, connectTimeout: const Duration(seconds: 5), receiveTimeout: const Duration(seconds: 3), )); Future> fetchHeroes() async { try { final response = await dio.get('/v2/heroes'); return response.data as List; } catch (e) { throw Exception('Failed to load heroes: $e'); } } Future> fetchHeroDetails(int id) async { try { final response = await dio.get('/v2/heroes/$id'); return response.data as Map; } catch (e) { throw Exception('Failed to load hero details: $e'); } } }