How do I open an external url in flutter web in new tab or in same tab How do I open an external url in flutter web in new tab or in same tab dart dart

How do I open an external url in flutter web in new tab or in same tab


I think you want this — dart:js enables interoperability between Dart and JS —:

import 'dart:js' as js;// ...FlatButton(  child: Text('Button'),  onPressed: () {    js.context.callMethod('open', ['https://stackoverflow.com/questions/ask']);  },)


One simple way is to just create a button and use dart:html's window.open() method:

import 'dart:html' as html;// ...html.window.open('https://stackoverflow.com/questions/ask', 'new tab');

The name parameter — which I left as 'new tab' — refers to the new tab's window name, about which you can learn more from MDN's documentation.


https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher_web

url_launcher has been the solution for android and ios, recently it added support for web.