decodeAs<T> method

T? decodeAs<T>(
  1. String jsonVal
)

Implementation

T? decodeAs<T>(String jsonVal) {
  if (T == String) {
    return jsonVal as T;
  }

  // Remove all spaces.  Ne|cessary for reg expressions as well.
  final targetType = "$T".replaceAll(' ', '');

  var decodedJson = json.decode(jsonVal);
  return _deserialize(decodedJson, targetType) as T?;
}