getScalarType method

Type getScalarType (
  1. Type type
)

Implementation

Type getScalarType(Type type) {
  var result = dynamic;
  final typeInfo = getTypeInfo(type);
  final scalarTypeName = typeInfo.scalarTypeName;

  /// Known Types
  if (typeInfo.scalarType != null) {
    return typeInfo.scalarType;
  }

  /// Custom Types annotated with [@jsonSerializable]
  if (classes[scalarTypeName] != null) {
    return classes[scalarTypeName].reflectedType;
  }

  /// Search through value decorators for scalarType match
  valueDecorators.keys.forEach((Type type) {
    if (type.toString() == scalarTypeName) {
      result = type;
    }
  });

  return result;
}