fetchAll method

Future<List<T>> fetchAll(
  1. String endpoint
)

Implementation

Future<List<T>> fetchAll(String endpoint) async {
  final response = await http.get(Uri.parse('$baseUrl/$endpoint'));

  if (response.statusCode == 200) {
    final List<dynamic> data = json.decode(response.body);
    return data.map((json) => instance.fromJson(json)).toList();
  } else {
    throw Exception('Erro na chamada de serviço: ${response.statusCode}');
  }
}