import 'dart:html' show HttpRequest; import 'package:html/parser.dart' show parse; import 'package:html/dom.dart' show Element; // Get the sitemap content Future getSitemap() async { const path = 'sitemap.html'; try { return await HttpRequest.getString(path); } catch (e) { print('Couldn’t open $path'); } return 'Error'; } // Parse the list of elements and detect pages from this list Map detectPages(List sitemap, [String prefix]) { final links = {}; for (var elem in sitemap) { if (elem.outerHtml.contains('index')) { continue; } else if (elem.innerHtml.startsWith('> parseSitemap() async { final content = await getSitemap(); final sitemap = parse(content).getElementsByClassName('org-ul')[0].children; return detectPages(sitemap); }