getProductListType method Null safety

dynamic getProductListType(
  1. String key
)

Implementation

static ProductListType getProductListType(final String key) {
  final int pos = key.indexOf(_keySeparator);
  if (pos < 0) {
    throw Exception('Unknown key format without "$_keySeparator": $key');
  }
  final String value = key.substring(0, pos);
  for (final ProductListType productListType in ProductListType.values) {
    if (productListType.key == value) {
      return productListType;
    }
  }
  throw Exception('Unknown product list type: "$value" from "$key"');
}