import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:info_tren/models.dart'; import 'package:info_tren/utils/iterable_extensions.dart'; Future> getRemoteReleases() async { final Uri uri = Uri.parse('https://gitea.dcdev.ro/api/v1/repos/kbruen/info_tren/releases'); final response = await http.get(uri); final json = jsonDecode(response.body) as List; return json.map((e) => ChangelogEntry( version: ChangelogVersion.parse(e['tag_name']), description: e['body'], apkLink: (e['assets'] as List).where((e) => (e['name'] as String).contains('.apk')).map((e) => Uri.parse(e['browser_download_url'] as String)).firstOrNull, linuxLink: (e['assets'] as List).where((e) => (e['name'] as String).contains('infotren-linux')).map((e) => Uri.parse(e['browser_download_url'] as String)).firstOrNull, windowsLink: (e['assets'] as List).where((e) => (e['name'] as String).contains('-win.zip')).map((e) => Uri.parse(e['browser_download_url'] as String)).firstOrNull, )).toList(); }