linkify function

List<LinkifyElement> linkify(
  1. String text, {
  2. LinkifyOptions options = const LinkifyOptions(),
  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 = const LinkifyOptions(),
  List<Linkifier> linkifiers = defaultLinkifiers,
}) {
  var list = <LinkifyElement>[TextElement(text)];

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

  if (linkifiers.isEmpty) {
    return list;
  }

  for (var linkifier in linkifiers) {
    list = linkifier.parse(list, options);
  }

  return list;
}