import 'dart:convert'; import 'package:http/http.dart' as http; import '../models/github_event.dart'; class GithubService { static const String _baseUrl = 'https://api.github.com'; Future> getUserEvents(String username, String token) async { final response = await http.get( Uri.parse('$_baseUrl/users/$username/events'), headers: { 'Authorization': 'Bearer $token', 'Accept': 'application/vnd.github.v3+json', }, ); if (response.statusCode == 200) { final List jsonList = json.decode(response.body); return jsonList.map((json) => GithubEvent.fromJson(json)).toList(); } else { throw Exception('Failed to load GitHub events: ${response.statusCode}'); } } }