parseToggles function

Map<String, ToggleConfig> parseToggles(
  1. String body
)

Parses toggles from the server or local storage so that they can be used as structured data

Implementation

Map<String, ToggleConfig> parseToggles(String body) {
  final data = jsonDecode(body)['toggles'];
  // Check if there is anything to map over? Otherwise map might cause an error
  // Write a test that checks if the
  return {
    for (var toggle in data) toggle['name']: ToggleConfig.fromJson(toggle)
  };
}