decode method Null safety

dynamic decode(
  1. Request? request
)

Implementation

dynamic decode(Request? request) {
  switch (location) {
    case BindingType.query:
      {
        final queryParameters = request!.raw.uri.queryParametersAll;
        final value = request.body.isFormData
            ? request.body.as<Map<String, List<String>>>()[name!]
            : queryParameters[name!];
        if (value == null) {
          return null;
        }
        return _decoder!(value);
      }

    case BindingType.body:
      {
        if (request!.body.isEmpty) {
          return null;
        }
        return _decoder!(request.body);
      }
    case BindingType.header:
      {
        final header = request!.raw.headers[name!];
        if (header == null) {
          return null;
        }
        return _decoder!(header);
      }

    case BindingType.path:
      {
        final path = request!.path.variables[name];
        if (path == null) {
          return null;
        }
        return _decoder!(path);
      }
  }
}