0

I have a Flutter web project, started with flutter_web and migrated to 1.9, all works great but no way to make a external link work.

There're some solutions in stack overflow but any of the solutions don't seems to works as expected, tried all from this link and similar other ones, I supouse the accepted questions would work before 1.9.

Daniel
  • 1,007
  • 1
  • 11
  • 23

3 Answers3

3

With flutter 1.10, we can use universal_html package to open external link:

import 'package:universal_html/prefer_universal/html.dart' as html;
// ...
html.window.location.assign('https://stackoverflow.com');
Spatz
  • 18,640
  • 7
  • 62
  • 66
1

As of today, you can use url_launcher to open urls for flutter web app. It supports both relative and absolute urls. https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher_web

wz366
  • 2,840
  • 6
  • 25
  • 34
0

Now you can alternatively add url_launcher_web dependency along with url_launcher and then use launch and canLaunch functions from url_launcher package for your web project as if it was mobile.

# pubspec
  url_launcher: 5.2.7            # the newest version rather than ^5.1.4
  url_launcher_web: ^0.1.0

Seems like it's a temporary solution though, to be merged with the main url_launcher plugin. For now it only works on web but ruins the mobile build (Flutter v1.12.16-pre.35).

LuckyLizard
  • 415
  • 3
  • 13