as<T> method Null safety

T as<T>()

Returns previously decoded object as T.

This method is the synchronous version of decode. However, decode must have been called prior to invoking this method or an error is thrown.


T as<T>() {
  if (!hasBeenDecoded) {
    throw StateError("Attempted to access request body without decoding it.");

  return _cast<T>(_decodedData);