Flutter Web: Right click -> Browser Context Menu -> Open Link in New Tab
Asked Answered
U

1

7

I have a basic website using GetX for navigation. I have inkwells with ontap functions which navigate to a new view. Right now, if you right click these buttons there is no "open link in new tab/window", "save link as" or "copy link address".

Is there any way to get this functionality for Flutter Web?

Uncaredfor answered 27/7, 2021 at 11:17 Comment(0)
C
7

Edit:

Since Flutter version 2.10, you no longer need to switch to channel beta for this.

Maybe I'm answering this late, but this may help someone in the future.

At the moment of writing this it is possible to be done, it is bugged on the stable channel, but it works perfectly on channel beta.

Just switch to channel beta:

flutter channel beta
flutter upgrade

Then follow this instructions to add url_launcher dependency to your project and import this package wherever you want to use it:

import 'package:url_launcher/link.dart';

And finally wrap any widget with this:

Link(
    uri: Uri.parse('www.google.com'),
    builder: (context, function) {
      return InkWell(
          onTap: () => print('Do something'), 
          child: Text('Right clickable text')
      );
    });
Cinnamon answered 20/11, 2021 at 16:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.