def url_for(
        endpoint: str,
        *,
        _anchor: Optional[str]=None,
        _external: Optional[bool]=None,
        _method: Optional[str]=None,
        _scheme: Optional[str]=None,
        **values: Any,
) -> str:
    """Return the url for a specific endpoint.

    This is most useful in templates and redirects to create a URL
    that can be used in the browser.

    Arguments:
        endpoint: The endpoint to build a url for, if prefixed with
            ``.`` it targets endpoint's in the current blueprint.
        _anchor: Additional anchor text to append (i.e. #text).
        _external: Return an absolute url for external (to app) usage.
        _method: The method to consider alongside the endpoint.
        _scheme: A specific scheme to use.
        values: The values to build into the URL, as specified in
            the endpoint rule.
    """
    app_context = _app_ctx_stack.top
    request_context = _request_ctx_stack.top

    if request_context is not None:
        url_adapter = request_context.url_adapter
        if endpoint.startswith('.'):
            if request.blueprint is not None:
                endpoint = request.blueprint + endpoint
            else:
                endpoint = endpoint[1:]
        if _external is None:
            _external = False
    elif app_context is not None:
        url_adapter = app_context.url_adapter
        if _external is None:
            _external = True
    else:
        raise RuntimeError('Cannot create a url outside of an application context')

    if url_adapter is None:
        raise RuntimeError(
            'Unable to create a url adapter, try setting the the SERVER_NAME config variable.'
        )
    if _scheme is not None and not _external:
        raise ValueError('External must be True for scheme usage')

    app_context.app.inject_url_defaults(endpoint, values)
    try:
        url = url_adapter.build(
            endpoint, values, method=_method, scheme=_scheme, external=_external,
        )
    except BuildError as error:
        return app_context.app.handle_url_build_error(error, endpoint, values)

    if _anchor is not None:
        quoted_anchor = quote(_anchor)
        url = f"{url}#{quoted_anchor}"
    return url
Return the url for a specific endpoint.

    This is most useful in templates and redirects to create a URL
    that can be used in the browser.

    Arguments:
        endpoint: The endpoint to build a url for, if prefixed with
            ``.`` it targets endpoint's in the current blueprint.
        _anchor: Additional anchor text to append (i.e. #text).
        _external: Return an absolute url for external (to app) usage.
        _method: The method to consider alongside the endpoint.
        _scheme: A specific scheme to use.
        values: The values to build into the URL, as specified in
            the endpoint rule.