Repository navigation
[Android] Auto hyperlink links in a Text widget #40505
Description
Activity
- addedframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.c: new featureNothing broken; request for a new capabilityNothing broken; request for a new capability
on Sep 15, 2019 Maybe highlight.dart can help you
This is a sample
Highlight( text: data.content, style: TextStyle(color: Colors.blue), defaultStyle: TextStyle(color: Colors.black), patterns: { RegExp( r"(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+", ): HighlightedText( recognizer: (RegExpMatch e, int i) { return TapGestureRecognizer() ..onTap = () { launch(e.input.substring(e.start, e.end)); }; }, ), }, );
Seems like a nice workaround, but this feature should be included in the framework itself. Both Android and iOS are capable of doing that automatically (although I don't know if Flutter does that on iOS - it doesn't on Android).
Reacted by 神楽坂花火, Samuel Akabo and Ray Li- addedwould be a good packageSeparate Flutter package should be made for thisSeparate Flutter package should be made for this
on Sep 18, 2019 @Kwasow a few months back I faced the same problem and I created this package flutter_parsed_text, it uses
RichTextand comes with few built-in types like email, phone, and URL and if you need something custom like mentions or hashtags you can use Regex to do that.customer: chalk points out this is feasible on Android and iOS from the framework
- addedP3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectand removed
on Jun 28, 2023 - addedteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
on Jul 8, 2023 This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.- locked as resolved and limited conversation to collaborators
on Sep 28, 2023
Use case
I'm parsing a JSON file and displaying a string part of it in a Text widget in my flutter app. That text contains links to external websites. As of my knowledge there is no way of formating those links to become hyperlinks. This can only be done with a RichText widget, but it requires the developer to specify the link manualy.
Proposal
Native android TextView allows to set the
android:autoLink="web"and then the links are automatically formated and become clickable. An optional parameter should be added to the flutter Text widget that would enable that.