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
final massagedThemeInfo = themesContents;
// loop across each theme. we have to remove pathing
for (final dynamic oneTheme in themesContents) {
// create a new map so we don't have concurrent modificatin
final massagedSelectedTokenSets = <String, dynamic>{};
// loop across each token set in this theme
for (final 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;
}