While launching from an url launcher in flutter on simulator ,something caused an error?

Issue

[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<…>

I got this error while running it how to solve this problem. Here is my code which I was trying but it doesn’t opens the link and seems nothing occurs. I have installed the url launcher plugin ^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,
                      ),
                    ),
                  ),
                ),
              ),
            ),
          ),
        ],
      ),
    );

Solution

You likely need to restart your application.

I have encountered this same problem after importing package:url_launcher/url_launcher.dart before restarting my app. An app restart seems to resolve the error for me.

Answered By – Dane Emmerson

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.