Bind.query constructor Null safety
- String? name
Binds an HTTP query parameter to an ResourceController property or operation method argument.
When the incoming request's Uri
has a query key that matches name, the argument or property value is set to the query parameter's value. For example,
the request /users?foo=bar would bind the value
bar to the variable
@Operation.get() Future<Response> getUsers(@Bind.query("foo") String foo) async => ...;
name is compared case-sensitively, i.e.
foo are different.
Note that if the request is a POST with content-type 'application/x-www-form-urlencoded', the query string in the request body is bound to arguments with this metadata.
Parameters with this metadata may be String, bool, or any type that implements
parse (e.g., int.parse or DateTime.parse). It may also
be a List of any of the allowed types, for which each query key-value pair in the request Uri be available in the list.
If the bound parameter is a positional argument in a operation method, it is required for that method. A 400 Bad Request will be sent and the operation method will not be invoked if the request does not contain the query key.
If the bound parameter is an optional argument in a operation method, it is optional for that method. The value of the bound property will be null if it was not present in the request.
If the bound parameter is a property without any additional metadata, it is optional for all methods in an ResourceController. If the bound parameter is a property with requiredBinding, it is required for all methods in an ResourceController.
const Bind.query(this.name) : bindingType = BindingType.query, accept = null, require = null, ignore = null, reject = null;