getRequiredArg<T> static method

T getRequiredArg<T>(
  1. List<Object?> positional,
  2. int index,
  3. String paramName,
  4. String methodName,
)

Get a required positional argument with type checking.

Throws ArgumentError if the argument is missing or has wrong type.

Implementation

static T getRequiredArg<T>(
  List<Object?> positional,
  int index,
  String paramName,
  String methodName,
) {
  if (positional.length <= index) {
    throw ArgumentD4rtException(
      '$methodName: Missing required argument "$paramName" at position $index. '
      'Expected at least ${index + 1} arguments, got ${positional.length}',
    );
  }
  return extractBridgedArg<T>(positional[index], paramName);
}