isPrimitiveType property

bool isPrimitiveType

Determine whether the current instance is a primitive type, including bool, int, double, String.

Can be called in the following ways, 2.isPrimitiveType 2.runtimeType.isPrimitiveType

Implementation

bool get isPrimitiveType {
  if (this is Type) {
    return this == bool || this == int || this == double || this == String;
  } else {
    return this is bool || this is num || this is String;
  }
}