When building a web app using Dart & Flutter web, can we somehow get the URL used to launch the web app in Dart code? I need to build a web app for a tool that the user will locally deploy on one of his machines and then launch from browser. I need to be able to get the IP address/host name of the server in the web app and then do further gRPC/REST calls.
Update the <base href="/"> tag in web/index. html to the path where your app is hosted. For example, to host your Flutter app at my_app. dev/flutter_app , change this tag to <base href="/flutter_app/"> .
Android-only settings: forceWebView – If set to null or false , the URL is opened in the device's default browser; otherwise, the URL is launched in a WebView. enableJavaScript – If set to true , JavaScript is enabled in WebView. enableDomStorage – When the value is set to true , WebView enables DOM storage.
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.
As mentioned in the comments, you can use something like the following untested example:
import 'dart:html' as html;
...
// Use whichever of the following you need:
final url = html.window.location.href;
final hostname = html.window.location.hostname; // you probably need this one
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