AvailableAttributeGroups.loadFromJSONString constructor

AvailableAttributeGroups.loadFromJSONString(
  1. String attributeGroupsString
)

Load constructor; may throw an exception.

Implementation

AvailableAttributeGroups.loadFromJSONString(
  final String attributeGroupsString,
) {
  final dynamic inputJson = HttpHelper().jsonDecode(attributeGroupsString);
  final List<AttributeGroup> attributeGroups = <AttributeGroup>[];
  for (final dynamic item in inputJson as List<dynamic>) {
    attributeGroups.add(AttributeGroup.fromJson(item));
  }
  if (attributeGroups.isEmpty) {
    throw Exception(
        'Unexpected error: empty attribute groups from json string $attributeGroupsString');
  }
  _attributeGroups = attributeGroups;
}