mediaParser function

MediaType? mediaParser(
  1. String? mediaString
)
  • Method which converts the string value to the MediaType
  • Used for converting the string from native code to dart type

Example:

 String actionString = 'video'
 MediaType type = mediaParser(actionString);
 print(type);

Output:

 MediaType.video

Implementation

MediaType? mediaParser(String? mediaString) {
  MediaType? type;

  switch (mediaString) {
    case 'video':
      type = MediaType.video;
      break;
    case 'image':
      type = MediaType.image;
      break;
  }
  return type;
}