linkify function

List<LinkifyElement> linkify (
  1. String text,
  2. {LinkifyOptions options,
  3. List<Linkifier> linkifiers: defaultLinkifiers}
)

Turns text into a list of LinkifyElement

Use humanize to remove http/https from the start of the URL shown. Will default to false (if null)

Uses linkTypes to enable some types of links (URL, email). Will default to all (if null).

Implementation

List<LinkifyElement> linkify(
  String text, {
  LinkifyOptions options,
  List<Linkifier> linkifiers = defaultLinkifiers,
}) {
  var list = <LinkifyElement>[TextElement(text)];

  if (text == null || text.isEmpty) {
    return [];
  }

  if (linkifiers == null || linkifiers.isEmpty) {
    return list;
  }

  options ??= LinkifyOptions();

  linkifiers.forEach((linkifier) {
    list = linkifier.parse(list, options);
  });

  return list;
}