Link

Handles any kind of link.


The Link component is a drop-in replacement for the <a> tag.

When available, it uses client-side navigation (no page reload on click) and falls back to the default server-side navigation.

dart
return Link(
  to: '/about',
  child: .text('About'),
);

renders to

html
<a href="/about">About</a>

Client-Side Navigation

When using client-side routing, the Link component will override the default behavior of the <a> tag and use the Routers push() or replace() method to navigate to the target route when clicked.

Clicks that the browser would not handle as a plain navigation in the current tab are left to the browser: clicks with a modifier key (such as Ctrl or Cmd to open the link in a new tab) or a button other than the primary one, clicks whose default action was already prevented, and clicks on links with a target other than _self or with a download attribute.

Parameters

toStringrequired

The url to navigate to.


replacebooloptional

Whether to replace the route instead of pushing, defaults to 'false'.

Only affects client-side routing.


extraObjectoptional

The extra data to attach to the new route.

Only affects client-side routing.


preloadbooloptional

Whether to preload the target route when the link is hovered, defaults to 'true'.

Only affects client-side routing when using lazy routes.


targetTarget?optional

The target attribute value applied to the anchor element.

Any value other than Target.self leaves the click to the browser instead of using client-side navigation.


referrerReferrerPolicy?optional

The referrerpolicy attribute value applied to the anchor element.


classesString?optional

The class attribute value applied to the anchor element.


stylesStyles?optional

The style attribute value applied to the anchor element.


attributesMap<String, String>?optional

Other attribute values applied to the anchor element.


childComponent?optional

Child component to render inside the anchor element.


childrenList<Component>?optional

Child components to render inside the anchor element.