【问题标题】:Share content to social media using flutter WEB使用 Flutter WEB 将内容分享到社交媒体
【发布时间】:2020-07-14 12:18:08
【问题描述】:

我在flutter android / iOS上使用了几个库来共享内容,直到最近我想在flutter WEB上实现共享功能。虽然我使用了相同的库,但它给出了 MissingPluginException 错误。这很可能是因为 Flutter Web 平台没有配置。

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

代码:

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,
          )),
    );
  }
}

有没有办法做到这一点?或者任何已实现的 Web 插件?

【问题讨论】:

    标签: flutter web dart share


    【解决方案1】:

    我认为目前还没有任何共享插件提供 Flutter Web 支持。 尽管如此,您可以使用类似clipboard 的插件来复制您的用户需要分享的内容,并要求他们粘贴并发送给他们的朋友。

    【讨论】:

      【解决方案2】:

      对于文本,您可以使用share_plus:,但仍然很难与之共享图像,但对于文本,它可以正常工作

      【讨论】:

        【解决方案3】:

        我已经开始使用一个插件来检测应用程序是在桌面还是移动设备上运行。 https://pub.dev/packages/share_everywhere

        如果您在桌面上会弹出您选择的网络,在移动设备上它将使用标准的颤振共享库。

        让我知道你的想法以及我可以如何改进

        【讨论】:

          【解决方案4】:

          在 onPressed 方法中使用 setSate((){}) 方法并将您的逻辑放入其中。

          【讨论】:

          • 我认为这与 setState 方法没有任何关系。我正在使用 Flutter Web 并没有实现它。请在回答之前完整阅读问题
          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-08-24
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多