isSuitableForRequest method Null safety

bool isSuitableForRequest(
  1. String? requestMethod,
  2. List<String?> requestPathVariables
)

Checks if a request's method and path variables will select this binder.

Note that requestMethod may be null; if this is the case, only path variables are compared.

Implementation

bool isSuitableForRequest(
  String? requestMethod,
  List<String?> requestPathVariables,
) {
  if (requestMethod != null && requestMethod.toUpperCase() != httpMethod) {
    return false;
  }

  if (pathVariables.length != requestPathVariables.length) {
    return false;
  }

  return requestPathVariables.every(pathVariables.contains);
}