1988
1988

Reputation: 339

ERROR:flutter/runtime/dart_vm_initializer.cc(41) on url_launcher

I use HTTP launcher and found this error on my console log after I run debug on my android studio emulator:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method launch on channel plugins.flutter.io/url_launcher_android)

This is the code where it throw error:

Future<void> _launchMap() async {
    final url = widget.website;
    var uri = Uri.parse(url);
    if (!await launchUrl(uri)) {
      throw 'Could not launch';
    }
  }

this is my android manifest:

       <queries>
            <!-- If your app checks for call support -->
            <intent>
                <action android:name="android.intent.action.VIEW" />
                <data android:scheme="tel" />
            </intent>
            <intent>
                <action android:name="android.intent.action.VIEW" />
                <data android:scheme="https" />
            </intent>
        </queries>

I use the newest flutter version and I already follow the guide from https://pub.dev/packages/url_launcher, but it still can't direct the link that I want from my API

Upvotes: 3

Views: 28980

Answers (3)

eqrakhattak
eqrakhattak

Reputation: 563

Try writing directly. e.g.

TextSpan(
   text: translation(context).terms_of_service,
   style: AppTextStyles.kPrivacyPolicyStyleBlack,
   recognizer: TapGestureRecognizer()
     ..onTap = () => launchUrl(Uri.parse('https://carbee.com.au/terms')),
 )

Upvotes: 0

Xuuan Thuc
Xuuan Thuc

Reputation: 2521

If you are using hot restart or hot reload, it won't do the trick. Since Flutter has to inject plugin dependencies into the platform-specific parts of your app, hot restart/hot reload is not enough to trigger the injection. Check this issue for more.

Close the app and execute flutter run command.

Upvotes: 5

Nams
Nams

Reputation: 302

Try the following code:

Future<void> _launchMap() async {
       final url = widget.website;
       var uri = Uri.parse(url);
    if (await canLaunchUrl(url)) {
       await launchUrl(url);
   } else {
       throw 'Could not launch $url';
}}

Upvotes: 0

Related Questions