expects<T> method

T expects<T>(
  1. dynamic input,
  2. DogEngine engine, [
  3. String? message
])

Casts this object to type T if possible, otherwise throws a DogSerializerException.

Implementation

T expects<T>(dynamic input, DogEngine engine, [String? message]) {
  if (input is T) return input;
  throw DogSerializerException(
      message: message ?? "Expected type $T but got $runtimeType", converter: this);
}