isTypeFullyPrimitive function Null safety

bool isTypeFullyPrimitive(
  1. TypeMirror type
)

Implementation

bool isTypeFullyPrimitive(TypeMirror type) {
  if (type == reflectType(dynamic)) {
    return true;
  }

  if (type.isSubtypeOf(reflectType(List))) {
    return isTypeFullyPrimitive(type.typeArguments.first);
  } else if (type.isSubtypeOf(reflectType(Map))) {
    return isTypeFullyPrimitive(type.typeArguments.first) &&
        isTypeFullyPrimitive(type.typeArguments.last);
  }

  if (type.isSubtypeOf(reflectType(num))) {
    return true;
  }

  if (type.isSubtypeOf(reflectType(String))) {
    return true;
  }

  if (type.isSubtypeOf(reflectType(bool))) {
    return true;
  }

  return false;
}