Bind.path constructor Null safety

const Bind.path(
  1. String? name

Binds a route variable from RequestPath.variables to an ResourceController operation method argument.

Routes may have path variables, e.g., a route declared as follows has an optional path variable named 'id':


A operation method is invoked if it has exactly the same path bindings as the incoming request's path variables. For example, consider the above route and a controller with the following operation methods:

    class UserController extends ResourceController {
      Future<Response> getUsers() async => Response.ok(getAllUsers());
      Future<Response> getOneUser(@Bind.path("id") int id) async => Response.ok(getUser(id));

If the request path is /users/1, /users/2, etc., getOneUser is invoked because the path variable id is present and matches the Bind.path argument. If no path variables are present, getUsers is invoked.


const Bind.path(
    : bindingType = BindingType.path,
      accept = null,
      require = null,
      ignore = null,
      reject = null;