as<E> method

E as <E>()

Allow transformation back to popular data types For using these methods, We're assuming it is safe to transform to String

Implementation

E as<E>(){
  assert(_isStream != null && !_isStream);

  if( E == String )
    return asString() as E;
  else if( E.toString() == Map<String, dynamic>().runtimeType.toString() )
    return asMap() as E;
  else if( E.toString() == List<dynamic>().runtimeType.toString() )
    return asList() as E;
  else if( E == int )
    return asInt() as E;
  else if( E == double )
    return asDouble() as E;
  else if( E == num )
    return asNumber() as E;
  else if( E == bool )
    return asBool() as E;

  throw new Exception("Unsupported return type. Deserialize to one of the supported formats");
}