flutter - 使用 Flutter WEB 将内容分享到社交媒体
问题描述
我在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 插件?
解决方案
对于您可以使用的文本,share_plus:
但仍然很难与之共享图像,但是对于文本,它可以正常工作
推荐阅读
- excel - 如何遍历列并将每列中的某些值存储到它们自己的变量中?
- c++ - 如何指定 bazel 的并行链接作业数量,与构建作业分开?
- c++ - 带有谷歌时间戳的 Protobuf C++ 消息导致段错误
- javascript - 日期选择器未正确更新日期对象
- reactjs - 有没有办法将按钮处理程序添加到组件而不在每次更新时重新生成函数?
- vba - 在排序期间排除最后一行
- android - 何时在工具栏中使用 homeAsUpIndicator?
- micronaut - 创建多个具有相同接口的 HTTP 客户端
- php - Laravel Cors 中间件不适用于 POST 请求
- android - 为什么在西班牙语本地化 TimePickerDialog 中,“AM”会显示为“A.”?