tryType<T> method

void tryType<T>({
  1. required dynamic data,
})

Same as checkType but throws an exception if not of the expected type.

Implementation

void tryType<T>({required dynamic data}) {
  if (!checkType<T>(data: data)) {
    throw "variable was not of type '$T'";
  }
}