themesAsSection function
Accepts the contents of a $themes
JSON that was probably loaded from a file
Returns the $themes
changed so that it works in a single JSON structure
Implementation
List<dynamic> themesAsSection(List<dynamic> themesContents) {
// should copy by attribute to decouple
List<dynamic> massagedThemeInfo = themesContents;
// loop across each theme. we have to remove pathing
for (dynamic oneTheme in (themesContents)) {
// create a new map so we don't have concurrent modificatin
Map<String, dynamic> massagedSelectedTokenSets = {};
// loop across each token set in this theme
for (var oneSet
in (oneTheme['selectedTokenSets'] as Map<String, dynamic>).entries) {
massagedSelectedTokenSets[basename(oneSet.key)] = oneSet.value;
}
oneTheme['selectedTokenSets'] = massagedSelectedTokenSets;
//_print('massaged tokens in selectedTokenSets: $massagedSelectedTokenSets');
}
return massagedThemeInfo;
}