getHomeSections method

Future<List<HomeSection>> getHomeSections()

Retrieves the home sections of the music platform.

Implementation

Future<List<HomeSection>> getHomeSections() async {
  final data =
      await constructRequest("browse", body: {"browseId": feMusicHome});

  final sections = traverseList(data, ["sectionListRenderer", "contents"]);
  dynamic continuation = traverseString(data, ["continuation"]);
  while (continuation != null) {
    final data = await constructRequest("browse",
        query: {"continuation": continuation});
    sections
        .addAll(traverseList(data, ["sectionListContinuation", "contents"]));
    continuation = traverseString(data, ["continuation"]);
  }

  return sections.map(Parser.parseHomeSection).toList();
}