validateTarget<T> static method

T validateTarget<T>(
  1. Object? target,
  2. String typeName
)

Validate target type for instance methods/getters.

Throws ArgumentError if target is not the expected type.

Implementation

static T validateTarget<T>(Object? target, String typeName) {
  if (target is T) {
    return target;
  }
  throw ArgumentD4rtException(
    'Invalid target: expected $typeName, got ${target?.runtimeType}',
  );
}