linkify
डार्ट में निम्न स्तर के लिंक (पाठ, URL, ईमेल, फ़ोन नंबर, उपयोगकर्ता टैग) पार्सिंग पुस्तकालय।
डार्ट में निम्न स्तर के लिंक (पाठ, URL, ईमेल) पार्सिंग लाइब्रेरी
^1.0.0^2.1.0^1.0.0यह अंग्रेज़ी मूल स्नैपशॉट है। नवीनतम सामग्री GitHub पर देखें।
linkify pub packageLow-level link (text, URLs, emails, phone numbers, user tags) parsing library in Dart.
Required Dart >=2.12 (has null-safety support).
Install by adding this package to your pubspec.yaml:
dependencies:
linkify: ^5.0.0
import 'package:linkify/linkify.dart';
linkify("Made by https://cretezy.com person@example.com");
// Output: [TextElement: 'Made by ', UrlElement: 'https://cretezy.com' (cretezy.com), TextElement: ' ', EmailElement: 'person@example.com' (person@example.com)]
You can pass LinkifyOptions to the linkify method to change the humanization of URLs (turning https://example.com to example.com):
linkify("https://cretezy.com");
// [UrlElement: 'https://cretezy.com' (cretezy.com)]
linkify("https://cretezy.com", options: LinkifyOptions(humanize: false));
// [UrlElement: 'https://cretezy.com' (https://cretezy.com)]
humanize: Removes http/https from shown URLsremoveWww: Removes www. from shown URLslooseUrl: Enables loose URL parsing (should parse most URLs such as abc.com/xyz)
defaultToHttps: When used with [looseUrl], default to https instead of httpexcludeLastPeriod: Excludes . at end of URLsYou can pass linkifiers to linkify as such:
linkify("@cretezy", linkifiers: [UserTagLinkifier()]);
Available linkifiers:
EmailLinkifierUrlLinkifierPhoneNumberLinkifierUserTagLinkifierYou can write custom linkifiers for phone numbers or other types of links. Look at the URL linkifier for an example.
This is the flow:
parse in the linkifier with a list of LinkifyElement. This starts as [TextElement(text)][TextElement("Hello https://example.com")] would become [TextElement("Hello "), UrlElement("https://example.com")]linkify function. By default, this is URL and email linkifiers