सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
एक फ्लटर पैकेज जो टेक्स्ट के भीतर सही और टैप करने योग्य इंलाइन लिंक के निर्माण की अनुमति देता है। यह स्वचालित रूप से एक स्ट्रिंग में URL, ईमेल और फ़ोन नंबर का पता लगाता है और उन्हें इंटरैक्टिव तत्व के रूप में दिखाता है, जबकि टेक्स्ट सिलेक्शन क्षमता को बनाए रखता है। ऐसे रिच टेक्स्ट डिस्प्ले के लिए आदर्श जहां उपयोगकर्ताओं को एम्बेडेड लिंक के साथ इंटरैक्ट करने की आवश्यकता होती है बिना टेक्स्ट को कॉपी या हाइलाइट करने की क्षमता खोने के बिना। इस पैकेज का समर्थन एंड्रॉइड, आईओएस, वेब, मैकओएस, विंडोज और लिनक्स जैसे कई प्लेटफॉर्म के लिए है।
उपयोग
क्लिक करने योग्य लिंक के साथ रिच टेक्स्ट प्रदर्शित करना
लिंक कंटेंट में पाठ चयन सक्षम करें
इंटरैक्टिव चैट या संदेश इंटरफ़ेस का निर्माण करना
एप्प टेक्स्ट में संपर्क विवरण एम्बेड करना
स्वयं-उत्पादित सामग्री के समर्थन में स्वचालित लिंक
मुख्य विशेषताएँ
URL, ईमेल और फ़ोन नंबर का स्वचालित निर्धारण
टेक्स्ट चयन और कॉपी को बनाए रखता है
कस्टमाइज़ किए गए लिंक स्टाइल
क्रॉस-प्लेटफॉर्म संगतता
Text विजेट्स के साथ सरल एकीकरण
लिंक पर टैप गेस्चर का समर्थन करता है
इनके लिए उपयुक्त
चैट एप्लिकेशन्स
सोशल मीडिया फीड्स
दस्तावेज़ दर्शक
उपयोगकर्ता प्रोफ़ाइल विवरण
गतिशील पाठ के साथ सामग्री-समृद्ध यूआई
विचार योग्य बातें
सुसंगत दिखावट के लिए अतिरिक्त स्टाइलिंग की आवश्यकता हो सकती है
बड़े टेक्स्ट ब्लॉक के साथ प्रदर्शन प्रभाव
गैर-मानक लिंक पैटर्न के लिए सीमित कस्टमाइजेशन
प्रवेश लेबल का सावधानी से उपयोग करने की आवश्यकता है
लिंक के अलावा जटिल रिच टेक्स्ट प्रारूपण के लिए उपयुक्त नहीं है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
Selectable Autolink Text
Generate inline links that can be selected and tapped in text for Flutter
@overrideWidgetbuild(BuildContext context) {
returnSelectableAutoLinkText(
'''
Advanced
You can shrink url like https://github.com/miyakeryo/flutter_selectable_autolink_text
tel: 012-3456-7890
email: mail@example.com''',
style: TextStyle(color: Colors.green[800]),
linkStyle: TextStyle(color: Colors.purpleAccent),
highlightedLinkStyle: TextStyle(
color: Colors.purpleAccent,
backgroundColor: Colors.purpleAccent.withAlpha(0x33),
),
onTransformDisplayLink: AutoLinkUtils.shrinkUrl,
onTap: (url) async {
print('🌶Tap: $url');
final uri = Uri.parse(url);
if (awaitcanLaunchUrl(uri)) {
launchUrl(uri);
}
},
onLongPress: (url) {
print('🍔LongPress: $url');
Share.share(url);
},
);
}
Customized
You can customize link pattern.
@overrideWidgetbuild(BuildContext context) {
returnSelectableAutoLinkText(
'Custom links''\nHi! @screen_name.'' If you customize the regular expression, you can make them.'' #hash_tag',
linkStyle: TextStyle(color: Colors.deepOrangeAccent),
highlightedLinkStyle: TextStyle(
color: Colors.deepOrangeAccent,
backgroundColor: Colors.deepOrangeAccent.withAlpha(0x33),
),
linkRegExpPattern: '(@[\\w]+|#[\\w]+|${AutoLinkUtils.urlRegExpPattern})',
onTransformDisplayLink: AutoLinkUtils.shrinkUrl,
onTap: (url) => print('🍒Tap: $url'),
onLongPress: (url) => print('🍩LongPress: $url'),
);
}
More advanced usage
@overrideWidgetbuild(BuildContext context) {
final blueStyle = TextStyle(color: Colors.blueAccent);
final highlightedStyle = TextStyle(
color: Colors.blueAccent,
backgroundColor: Colors.blueAccent.withAlpha(0x33),
);
final orangeStyle = TextStyle(color: Colors.orange);
final boldStyle = TextStyle(fontWeight: FontWeight.bold);
final italicStyle = TextStyle(fontStyle: FontStyle.italic);
final bigStyle = TextStyle(fontSize: 24);
final regExpPattern = r'\[([^\]]+)\]\(([^\s\)]+)\)';
final regExp = RegExp(regExpPattern);
returnSelectableAutoLinkText(
'''
More advanced usage
[This is a link text](https://google.com)
[This text is bold](bold)
This text is normal
[This text is italic](italic)
[This text is orange](orange)
[This text is big](big)''',
linkRegExpPattern: regExpPattern,
onTransformDisplayLink: (s) {
final match = regExp.firstMatch(s);
if (match != null && match.groupCount == 2) {
final text1 = match.group(1)!;
final text2 = match.group(2)!;
switch (text2) {
case'bold':
returnLinkAttribute(text1, style: boldStyle);
case'italic':
returnLinkAttribute(text1, style: italicStyle);
case'orange':
returnLinkAttribute(text1, style: orangeStyle);
case'big':
returnLinkAttribute(text1, style: bigStyle);
default:
if (text2.startsWith('http')) {
returnLinkAttribute(
text1,
link: text2,
style: blueStyle,
highlightedStyle: highlightedStyle,
);
} else {
returnLinkAttribute(text1);
}
}
}
returnLinkAttribute(s);
},
onTap: (url) => launchUrl(Uri.parse(url)),
onLongPress: (url) => Share.share(url),
);
}