fetchGitHubReleaseData static method
Fetches GitHub release data from url and returns the parsed JSON map.
If githubToken is provided, it is sent as a Bearer token in the
Authorization header (used to raise GitHub API rate limits).
Returns null on any HTTP error or parse failure.
Implementation
static Future<Map<String, dynamic>?> fetchGitHubReleaseData(
String url, {
String? githubToken,
}) async {
final client = HttpClient();
try {
final request = await client.getUrl(Uri.parse(url));
request.headers.set('User-Agent', 'inno_bundle');
request.headers.set('Accept', 'application/json');
if (githubToken != null && githubToken.isNotEmpty) {
request.headers.set('Authorization', 'Bearer $githubToken');
}
final response = await request.close();
final body = await response.transform(utf8.decoder).join();
if (response.statusCode != 200) return null;
return jsonDecode(body) as Map<String, dynamic>;
} catch (_) {
return null;
} finally {
client.close();
}
}