assertType function

void assertType(
  1. dynamic val,
  2. List types, {
  3. String? message,
})

Implementation

void assertType(dynamic val, List<dynamic> types, {String? message}) {
  if (types.any((type) => val.runtimeType.toString() == type)) {
    throw ArgumentError(
        message ?? "Invalid arg: $val type should be ${types.join(" or ")}");
  }
}