url_launcher 部署后在 flutter web 上抛出 MissingPluginException

问题描述 投票:0回答:2

我想从浏览器打开系统的电子邮件程序,我通过调用来完成此操作

TextSpan(
    text: '[email protected]',
    style: Theme.of(context).textTheme.bodyMedium!.copyWith(
         color: Theme.of(context).primaryColor,
         fontWeight: FontWeight.bold,
    ),
    recognizer: TapGestureRecognizer()
                    ..onTap = () async {
                      await launchUrl(
                        Uri(
                          scheme: 'mailto',
                          path: '[email protected]',
                        ),
                      );
                    })

当我在本地测试代码时(也使用 --release 构建),一切正常,但是一旦我将应用程序部署到 firebase 托管,它就会返回一个

Uncaught Error: MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher)

我的本地发布版本和我上传到 Firebase 托管的版本有什么区别? 为什么它突然给我这个 MissingPluginException?

firebase flutter-web firebase-hosting url-launcher
2个回答
0
投票

我遇到了同样的问题。在我的 pubspec 文件中添加 url_launcher_web 作为依赖项解决了我的问题。

flutter pub add url_launcher_web


0
投票

发现此评论,它对我的情况有帮助:

使用“flutter clean”清理构建并重建

© www.soinside.com 2019 - 2024. All rights reserved.