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
相关问题
- What means in Dart static type and why it differs
- Flutter : Prepare list data from http request
- How to schedule an alarm on specific time in Flutt
- MappedListIterable is not a SubType
- 'firebase_messaging/FirebaseMessagingPlugin.h&
相关文章
- Observatory server failed to start - Fails to crea
- Flutter error retrieving device properties for ro.
- Adding Shadows at the bottom of a container in flu
- Flutter. Check if a file exists before loading it
- Flutter - http.get fails on macos build target: Co
- Receive share file intents with Flutter
- Do stateless widgets dispose on their own?
- How to clean your build with Flutter RP2 in Androi
You can use the url_launcher plugin
Then in your code
Example taken from the package site
I think you want this:
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.Answered here https://stackoverflow.com/a/56656885/361832
Flutter Web does not support plugins (yet), so you have to use replacements from
dart:html
https://api.dartlang.org/stable/2.4.0/dart-html/Window/open.html window.open(url, 'tab');
or
https://api.dartlang.org/stable/2.4.0/dart-html/Window/location.html window.location.assign(url);
One simple way is to just create a button and use
dart:html
'swindow.open()
method: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.