matchValueType static method

bool matchValueType(
  1. dynamic expectedType,
  2. dynamic actualValue
)

Matches expected type to a type of a value. The expected type can be specified by a type, type name or TypeCode.

  • expectedType an expected type to match.
  • actualValue a value to match its type to the expected one. Returns true if types are matching and false if they don't.

See matchType See matchValueTypeByName (for matching by types' string names)

Implementation

static bool matchValueType(expectedType, actualValue) {
  if (expectedType == null) return true;
  if (actualValue == null) throw Exception('Actual value cannot be null');

  return matchType(expectedType, TypeConverter.toTypeCode(actualValue));
}