Link class
Hyperlink element (<a>) with built-in client-side routing and prefetch capabilities.
Wraps standard HTML anchor attributes and adds integration with PrefetchMode and BloomRouter.prefetch.
Prefetching Behavior
- PrefetchMode.off: No prefetching is performed.
- PrefetchMode.hover: Preloads route loaders and components on
pointerenter/mouseenter. - PrefetchMode.visible: Marks the element with
data-bloom-prefetch="visible"for viewport intersection prefetching viaBloomRouterController.
Prefetching is opt-in, session-idempotent per clean path, and ignores network or evaluation errors.
// Basic link
Link(href: '/about', text: 'About Us')
// Hover-based prefetching
Link(href: '/dashboard', prefetch: PrefetchMode.hover, text: 'Dashboard')
// Viewport visibility prefetching with child nodes
Link(
href: '/pricing',
prefetch: PrefetchMode.visible,
children: [
const Span(className: 'icon', text: 'tag'),
const Span(text: 'View Pricing'),
],
)
Constructors
-
Link({required String href, PrefetchMode prefetch = PrefetchMode.off, String? text, String? className, String? style, Map<
String, String> ? attrs, List<BloomNode> children = const [], Map<String, BloomEventHandler> ? on, BloomEventHandler? onClick}) -
Creates a hyperlink element targeting
hrefwith optionalprefetchbehavior. -
Link.raw({String? text, String? className, String? style, Map<
String, String> ? attrs, Map<String, BloomEventHandler> ? on, List<BloomNode> children = const [], PrefetchMode prefetch = PrefetchMode.off}) -
Creates a const Link descriptor without dynamic event bindings.
const
Properties
-
attrs
→ Map<
String, String> ? -
Arbitrary HTML attributes (id, href, placeholder, etc.).
finalinherited
-
children
→ List<
BloomNode> -
Child descriptors nested within this element.
finalinherited
- className → String?
-
CSS class attribute applied to the element.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
on
→ Map<
String, BloomEventHandler> ? -
Event handlers keyed by DOM event name (click, input, change...).
finalinherited
- prefetch → PrefetchMode
-
Speculative prefetching strategy for this link's destination URL.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- style → String?
-
Inline style — raw CSS string (e.g. "color: red; display: flex;").
finalinherited
- tag → String
-
Lowercase tag name, e.g. "div", "button", "custom-tag".
finalinherited
- text → String?
-
Optional single text child sugar — equivalent to
children: [Text(text)]when no explicit children are given.finalinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited