Skip to content

[url_launcher] [Web] Clicking on Link without calling followLink function still takes user to that link. #162927

Closed
flutter/packages
#8675

Description

@aarajput

Steps to reproduce

If you wrap a ElevatedButton with Link widget on web, and don't pass followLink function to ElevatedButton, when you click on that ElevatedButton button, it still takes user to that link.

Expected results

It should only take user to that link when followLink function is called

Actual results

Even i am not passing followLink function to ElevatedButton's onPressed property but Its still opening link that i set in uri of Link widget.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:url_launcher/link.dart' as ul;

class GoogleButton extends StatelessWidget {
  const GoogleButton();

  @override
  Widget build(final BuildContext context) {
    return ul.Link(
      uri: Uri.parse('https://google.com'),
      target: ul.LinkTarget.blank,
      builder: (context, followLink) => ElevatedButton(
        onPressed: null,
        child: Text('Open Google'),
      ),
    );
  }
}

Screenshots or Video

No response

Logs

No response

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.27.4, on macOS 15.2 24C101 darwin-arm64, locale en-PK)
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.3)
[✓] Connected device (4 available)
[✓] Network resources

Activity

  1. stuartmorgan-g commented on Feb 8, 2025

    @stuartmorgan-g
    Contributor

    Could you describe the use case for this code? What is the effect you are trying to achieve by using Link but not using followLink as the documentation says to do?

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 8, 2025
  3. aarajput commented on Feb 8, 2025

    @aarajput
    Author

    I have custom implementation, when elevated button is clicked, i update my state, and then that state updates route.
    And i use Link because user can right click on my elevated button and open that link in new tab.

  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Feb 8, 2025
  5. aarajput commented on Feb 9, 2025

    @aarajput
    Author
  6. darshankawar commented on Feb 10, 2025

    @darshankawar
    Member

    builder: (context, followLink) => ElevatedButton(
    onPressed: null,

    The difference I observed if we pass followLink to onPressed is that the button gets activated upon cursor or mouse hover over the button. If we pass null to it, the hover effect doesn't take place while the button is tappable and opens the link.

    Will keep the issue open for the use case described.

  7. added
    platform-webWeb applications specifically
    p: url_launcherPlugin to launch external applications
    packageflutter/packages repository. See also p: labels.
    team-webOwned by Web platform team
    and removed
    in triagePresently being triaged by the triage team
    on Feb 10, 2025
  8. added
    P2Important issues not at the top of the work list
    triaged-webTriaged by Web platform team
    P1High-priority issues at the top of the work list
    and removed
    P2Important issues not at the top of the work list
    on Feb 12, 2025
  9. added
    r: fixedIssue is closed as already fixed in a newer version
    on Feb 27, 2025
  10. github-actions commented on Mar 13, 2025

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

  11. locked as resolved and limited conversation to collaborators on Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listp: url_launcherPlugin to launch external applicationspackageflutter/packages repository. See also p: labels.platform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions