fromStringValue static method

GiphyRating fromStringValue(
  1. String value
)

Converts a string value to a corresponding GiphyRating enum value.

Throws an ArgumentError if the given string does not match any GiphyRating values.

value The string representation of the Giphy rating.

Returns the matching GiphyRating value.

Implementation

static GiphyRating fromStringValue(String value) {
  switch (value) {
    case 'r':
      return GiphyRating.r;
    case 'y':
      return GiphyRating.y;
    case 'g':
      return GiphyRating.g;
    case 'pg':
      return GiphyRating.pg;
    case 'pg13':
      return GiphyRating.pg13;
    case 'unrated':
      return GiphyRating.unrated;
    case 'nsfw':
      return GiphyRating.nsfw;
    default:
      throw ArgumentError('Invalid rating type: $value');
  }
}