getChromiumDownloadUrl function

Future<String> getChromiumDownloadUrl()

Implementation

Future<String> getChromiumDownloadUrl() async {
  final response =
      await http.get(Uri.parse("https://omahaproxy.appspot.com/all.json"));
  final data = jsonDecode(response.body) as List<dynamic>;
  final latest =
      data.firstWhere((element) => element['os'] == 'win', orElse: () => null);
  if (latest != null) {
    final version = latest['versions'].firstWhere(
        (element) => element['channel'] == 'stable',
        orElse: () => null);
    if (version != null) {
      return "$CHROMIUM_DOWNLOAD_SOURCE${version['branch_base_position']}/chrome-win.zip";
    }
  }
  return "";
}