I have a simple web app I have created with flutter web. I would like to know how I can open new an external url
either in a new tab
or in the same tab
in my flutter web app. say I want to open the url https://stackoverflow.com/questions/ask
Here, we have two pages, FIRST_PAGE (Example: localhost:3000/#/first_page) and SECOND_PAGE (Example: localhost:3000/#/second_page). Now, we will create a reusable onGenerateRoute class in our second routes file. Using the route settings, we will get the Routes name and then navigate to the corresponding Page.
linkify Flutter plugin can turn text URL and email to a clickable inline text. First, add flutter_linkify plugin to your project. Next import to the file which you are going to implement the code. print("Linkify link = ${link.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With