6

I Am unable to use the firebase dynamic links plugin on flutter web.

When am trying to create a deep link it gives error:

Error: MissingPluginException(No implementation found for method DynamicLinkParameters#buildShortLink on channel plugins.flutter.io/firebase_dynamic_links)
    at Object.throw_ [as throw] (http://localhost:49242/dart_sdk.js:5344:11)
    at MethodChannel._invokeMethod (http://localhost:49242/packages/flutter/src/services/system_channels.dart.lib.js:962:21)
    at _invokeMethod.next (<anonymous>)
    at http://localhost:49242/dart_sdk.js:39201:33
    at _RootZone.runUnary (http://localhost:49242/dart_sdk.js:39058:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:49242/dart_sdk.js:34044:29)
    at handleValueCallback (http://localhost:49242/dart_sdk.js:34604:49)
    at Function._propagateToListeners (http://localhost:49242/dart_sdk.js:34642:17)
    at _Future.new.[_completeWithValue] (http://localhost:49242/dart_sdk.js:34484:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:49242/dart_sdk.js:34507:35)
    at Object._microtaskLoop (http://localhost:49242/dart_sdk.js:39345:13)
    at _startMicrotaskLoop (http://localhost:49242/dart_sdk.js:39351:13)
    at http://localhost:49242/dart_sdk.js:34858:9

Also while at init state when trying to handle dynamic links it gives a similar type error.

How to solve this? I need to create a dynamic link at least in my flutter web project.

Jagadish
  • 1,005
  • 11
  • 30
  • have you find any solution?? if yes plese answere to my question, https://stackoverflow.com/questions/70847741/flutter-dynamic-links-open-web-page-when-app-is-not-installed – Jitendra Mistry Jan 26 '22 at 05:54

3 Answers3

5

you can build the dynamic links using a post request to Dynamiclinks API using this guide like this:

    Future<String>? buildDynamicLinks(
      {theID, theTitle, theDescription, companyName, theCategory}) async {
    var  urlToReturn;
    final String postUrl =
        'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key=*****YourApiKey******';

    String theUrl =
        "https://sample.page.link/?isi=3223&ibi=app.sample.example&imv=1.0.1&link=https%3A%2F%2Fwww.yourWebsite.net%2F${theCategory ?? 'id'}%2F$theID&si=**imgUrl**&sd=$companyName  -  $theDescription&amv=1&st=$theTitle&apn=app.example.sample";

    await http.post(Uri.tryParse(postUrl)!, body: {
      'longDynamicLink': theUrl,
    }).then(
      (http.Response response) {
        final int statusCode = response.statusCode;

        if (statusCode < 200 || statusCode > 400 || response == null) {
          throw new Exception("Error while fetching data");
        }
        var decoded = json.decode(response.body);
        urlToReturn = decoded['shortLink'];
        return decoded['shortLink'];
      },
    ).catchError((e) => debugPrint('error $e'));
    return urlToReturn;
  }
Hooshyar
  • 1,181
  • 4
  • 12
  • 28
4

The Error

Error: MissingPluginException(No implementation found for method DynamicLinkParameters#buildShortLink on channel plugins.flutter.io/firebase_dynamic_links)

This error is because there is actually no web implementation for the Firebase Dynamic Links plugin package. Consult this chart for details.

Solution: Exclude Web

When you are retrieving your initial link during app startup, you can exclude Flutter Web from attempting to do this using the kIsWeb variable.

Example:

// Firebase: Get any initial dynamic links (not compatible with web)
dynamic initialLink;
if (!kIsWeb) {
  initialLink = await FirebaseDynamicLinks.instance.getInitialLink();
}

// Do something with initialLink

The initialLink variable will be nullable, so you will have to incorporate null checks into your iOS / Android platform handling code.

How Firebase Dynamic Links Work on Web

When setting up your Dynamic Link in the Firebase Console, you input a "deep link url" which is the web browser location the link forwards to if the app is not installed. This should be the URL you want the dynamic link to forward to in the web version of your app.

If you are using Navigator 2 based routing with a package such as go_router (I'm including this one because it's maintained by the flutter dev team), you can declare which screen / widget should load for the given deep link url.

Matthew Rideout
  • 7,330
  • 2
  • 42
  • 61
1

Currently the firebase_dynamic_links plugin is not supported for the web platform.

The displayed error message MissingPluginException(No implementation found for method DynamicLinkParameters...) indicates that.

All packages available in pub.dev have some tags that indicates the supported platforms.