getLibraryContents function
Parses contents from library.
Implementation
JsonMap? getLibraryContents(JsonMap response, List renderer) {
final section = nav(
response,
SINGLE_COLUMN_TAB + SECTION_LIST,
nullIfAbsent: true,
);
JsonMap? contents;
if (section == null) {
final numTabs = (nav(response, [...SINGLE_COLUMN, 'tabs']) as List).length;
final libraryTab = numTabs < 3 ? TAB_1_CONTENT : TAB_2_CONTENT;
contents =
nav(
response,
SINGLE_COLUMN + libraryTab + SECTION_LIST_ITEM + renderer,
nullIfAbsent: true,
)
as JsonMap?;
} else {
final results = findObjectByKey(section as List, 'itemSectionRenderer');
if (results == null) {
contents =
nav(
response,
SINGLE_COLUMN_TAB + SECTION_LIST_ITEM + renderer,
nullIfAbsent: true,
)
as JsonMap?;
} else {
contents =
nav(results, ITEM_SECTION + renderer, nullIfAbsent: true) as JsonMap?;
}
}
return contents;
}