【问题标题】:While launching from an url launcher in flutter on simulator ,something caused an error?在模拟器上从 url 启动器启动时,出现错误?
【发布时间】:2020-09-23 22:41:11
【问题描述】:
[VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: MissingPluginException(No implementation found for method canLaunch on channel plugins.flutter.io/url_launcher)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:154:7)
<asynchronous suspension>
#1      MethodChannel.invokeMethod  (package:flutter/src/services/platform_channel.dart:329:12)
#2      MethodChannelUrlLauncher.canLaunch (package:url_launcher_platform_interface/method_channel_url_launcher.dart:18:21)
#3      canLaunch (package:url_launcher/url_launcher.dart:111:45)
#4      _ProfileState.buildProfileHeader.<anonymous closure>.<anonymous closure> (package:focal/pages/profile.dart:475:31)
#5      _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:779:19)
#6      _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:862:36)
#7      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
#8      TapGestureRecognizer.ha<…>

运行时出现此错误如何解决此问题。这是我正在尝试的代码,但它没有打开链接,似乎什么也没发生。我已经安装了 url 启动器插件 ^5.4.10

String test = 'www.fiverr.com/share/yv32Eb';


Padding(
            padding: EdgeInsets.only(top: 2, left: 5),
            child: InkWell(
              splashColor: Colors.green.withOpacity(0.3),
              onTap: () async {
                if (await canLaunch(test)) {
                  await launch(test);
                }
                print('nothing');
              },
              child: Center(
                child: Padding(
                  padding: EdgeInsets.only(top: 2),
                  child: SizedBox(
                    height: 20,
                    width: MediaQuery.of(context).size.width * 0.5,
                    child: Text(
                      'www.fiverr.com/share/hifhsjbfvbhvs/ihfahiuhf/ahaknn?/;kjiuasnjkc',
                      overflow: TextOverflow.ellipsis,
                      maxLines: 1,
                      style: TextStyle(
                        color: Colors.green,
                        fontWeight: FontWeight.bold,
                        letterSpacing: 1.5,
                        fontSize: 13,
                      ),
                    ),
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );

【问题讨论】:

  • 尝试停止应用程序并执行flutter clean然后再次运行应用程序

标签: flutter dart flutter-layout flutter-dependencies dart-pub


【解决方案1】:

您可能需要重新启动您的应用程序。

在重新启动我的应用程序之前导入package:url_launcher/url_launcher.dart 后,我遇到了同样的问题。重新启动应用似乎可以解决我的错误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-09-03
    • 2011-03-22
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 2016-03-20
    相关资源
    最近更新 更多