isValueCompatibleWithTypeArgument method

bool isValueCompatibleWithTypeArgument(
  1. Object? value,
  2. int typeArgumentIndex
)

Check if a value is compatible with the expected generic type at the given index

Implementation

bool isValueCompatibleWithTypeArgument(Object? value, int typeArgumentIndex) {
  if (typeArguments == null || typeArgumentIndex >= typeArguments!.length) {
    // No type constraints, allow any value
    return true;
  }

  final expectedType = typeArguments![typeArgumentIndex];
  return _isValueCompatibleWithType(value, expectedType);
}