1
votes

I've used several libraries on sharing content on the flutter android/iOS until recently I wanted to implement the sharing functionality on the flutter WEB. Though I used the same libraries but it gives an error of MissingPluginException. Which is most probably because there is no configuration for the Flutter Web Platform.

Overflow on channel: social_share.  Messages on this channel are being discarded in FIFO fashion.  The engine may not be running or you need to adjust the buffer size if of
the channel.
Error: MissingPluginException(No implementation found for method shareWhatsapp on channel social_share)
    at Object.throw_ [as throw] (http://localhost:58884/dart_sdk.js:4314:11)
    at MethodChannel._invokeMethod (http://localhost:58884/packages/flutter/src/services/platform_channel.dart.lib.js:410:21)
    at _invokeMethod.next (<anonymous>)
    at http://localhost:58884/dart_sdk.js:37184:33
    at _RootZone.runUnary (http://localhost:58884/dart_sdk.js:37038:58)
    at _FutureListener.thenAwait.handleValue (http://localhost:58884/dart_sdk.js:32022:29)
    at handleValueCallback (http://localhost:58884/dart_sdk.js:32569:49)
    at Function._propagateToListeners (http://localhost:58884/dart_sdk.js:32607:17)
    at _Future.new.[_completeWithValue] (http://localhost:58884/dart_sdk.js:32450:23)
    at async._AsyncCallbackEntry.new.callback (http://localhost:58884/dart_sdk.js:32472:35)
    at Object._microtaskLoop (http://localhost:58884/dart_sdk.js:37299:13)
    at _startMicrotaskLoop (http://localhost:58884/dart_sdk.js:37305:13)
    at http://localhost:58884/dart_sdk.js:32824:9

Code:

class SocialMediaLogo extends StatelessWidget {
  final String logo;
  SocialMediaLogo(this.logo);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.all(5),
      child: RaisedButton(
          onPressed: () async {
            SocialShare.shareWhatsapp("Hello World \n https://google.com")
                .then((data) {
              print(data);
            });
          },
          child: Image(
            image: AssetImage("icons/$logo.png"),
            height: 35,
            width: 35,
            fit: BoxFit.cover,
          )),
    );
  }
}

Is there any way to do this? Or any implemented Web plugin for it?

4

4 Answers

0
votes

I don't think any sharing plugins yet provide Flutter web support. Nonetheless, you could use something like clipboard plugin to copy content which your users need to share and ask them to paste and send it to their friends.

0
votes

for text you can use share_plus: but still its hard to share images with it, but for texts it works fine

0
votes

I've started on a plugin that detects if the app is running on Desktop or Mobile. https://pub.dev/packages/share_everywhere

If your on desktop it will popup with the networks you choose, on mobile it will use the standard flutter share library.

Let me know what you think and how I can improve

-1
votes

Use setSate((){}) method in onPressed method and put your logic into it.