a function

Component a(
  1. List<Component> children, {
  2. String? download,
  3. required String href,
  4. Target? target,
  5. String? type,
  6. ReferrerPolicy? referrerPolicy,
  7. Key? key,
  8. String? id,
  9. String? classes,
  10. Styles? styles,
  11. Map<String, String>? attributes,
  12. Map<String, EventCallback>? events,
})

The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email addresses, locations in the same page, or anything else a URL can address.

Content within each <a> should indicate the link's destination. If the href attribute is present, pressing the enter key while focused on the <a> element will activate it.

  • download: Causes the browser to treat the linked URL as a download. Can be used with or without a value:

    Without a value, the browser will suggest a filename/extension, generated from various sources: The Content-Disposition HTTP header The final segment in the URL path The media type (from the Content-Type header, the start of a data: URL, or Blob.type for a blob: URL) Defining a value suggests it as the filename. / and \ characters are converted to underscores (_). Filesystems may forbid other characters in filenames, so browsers will adjust the suggested name if necessary.

  • href: The URL that the hyperlink points to. Links are not restricted to HTTP-based URLs — they can use any URL scheme supported by browsers:

    Sections of a page with fragment URLs Pieces of media files with media fragments Telephone numbers with tel: URLs Email addresses with mailto: URLs While web browsers may not support other URL schemes, web sites can with registerProtocolHandler()

  • target: Where to display the linked URL, as the name for a browsing context (a tab, window, or <iframe>).

  • type: Hints at the linked URL's format with a MIME type. No built-in functionality.

  • referrerPolicy: How much of the referrer to send when following the link.

Implementation

Component a(List<Component> children,
    {String? download,
    required String href,
    Target? target,
    String? type,
    ReferrerPolicy? referrerPolicy,
    Key? key,
    String? id,
    String? classes,
    Styles? styles,
    Map<String, String>? attributes,
    Map<String, EventCallback>? events}) {
  return DomComponent(
    tag: 'a',
    key: key,
    id: id,
    classes: classes,
    styles: styles,
    attributes: {
      ...attributes ?? {},
      if (download != null) 'download': download,
      'href': href,
      if (target != null) 'target': target.value,
      if (type != null) 'type': type,
      if (referrerPolicy != null) 'referrerpolicy': referrerPolicy.value,
    },
    events: events,
    children: children,
  );
}