首页 > 解决方案 > 如何找到为 Flutter Web 应用程序提供服务的 URL?

问题描述

我希望我的 webapp 在以下位置可用:

  http://example.com/ui/      # My flutter web application
  http://example.com/api/...  # REST endpoints

如何找到下载我的应用程序的 URL ( http://example.com/ui/),以便从中生成 URL http://example.com/api/

我宁愿不将其烘焙example.com到 webapp 中,因为我们在 CI 期间部署到许多具有不同域名的集群。

标签: flutterflutter-web

解决方案


import 'dart:html' as html;

...
debugPrint('host=${html.window.location.host + html.window.location.pathname}');
...

推荐阅读