Skip to content

[Android] Auto hyperlink links in a Text widget #40505

Description

@Kwasow

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.

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    c: new featureNothing broken; request for a new capability
    on Sep 15, 2019
  2. KagurazakaHanabi commented on Sep 18, 2019

    @KagurazakaHanabi

    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));
              };
          },
        ),
      },
    );
  3. Kwasow commented on Sep 18, 2019

    @Kwasow
    Author

    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).

  4. fayeed commented on Oct 23, 2019

    @fayeed

    @Kwasow a few months back I faced the same problem and I created this package flutter_parsed_text, it uses RichText and 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.

  5. xster commented on May 1, 2023

    @xster
    Member

    customer: chalk points out this is feasible on Android and iOS from the framework

  6. self-assigned this
    on May 2, 2023
  7. added
    P3Issues that are less important to the Flutter project
    and removed on Jun 28, 2023
  8. github-actions commented on Sep 28, 2023

    @github-actions

    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 -v and a minimal reproduction of the issue.

  9. locked as resolved and limited conversation to collaborators on Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilitycustomer: chalk (g3)frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework teamwould be a good packageSeparate Flutter package should be made for this

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions