title: Enum from String
body: <p>I have an <code>Enum</code> and a function to create it from a <code>String</code> because i couldn't find a built in way to do it</p>
  
  
  
  <pre class="lang-dart prettyprint-override"><code>enum Visibility{VISIBLE,COLLAPSED,HIDDEN}
  
  Visibility visibilityFromString(String value){
    return Visibility.values.firstWhere((e)=&gt;
        e.toString().split('.')[1].toUpperCase()==value.toUpperCase());
  }
  
  //used as
  Visibility x = visibilityFromString('COLLAPSED');
  </code></pre>
  
  <p>but it seems like i have to rewrite this function for every Enum i have, is there a way to write the same function where it takes the Enum type as parameter? i tried to but i figured out that i can't cast to Enum.</p>
  
  <pre class="lang-dart prettyprint-override"><code>//is something with the following signiture actually possible?
       dynamic enumFromString(Type enumType,String value){
  
       }
  </code></pre>