shareToWechatOrTimeline method
dynamic
shareToWechatOrTimeline(
分享微信或者朋友圈
Implementation
shareToWechatOrTimeline(
BuildContext context, {
String? bizId,
required int bizType,
required int shareType,
String? title,
String? description,
WeChatImage? thumbnailImage,
}) async {
ShareDataModel? shareDataModel = await requestShare(
bizId: bizId,
bizType: bizType,
shareType: shareType,
);
if (shareDataModel == null) {
return; // 不需要再toast,上述 request 失败的时候就会内部自动 toast
}
if (shareDataModel.landingUrl == null) {
BaseShareSingleton.toastHandle?.call("分享失败");
return;
}
String webPage = shareDataModel.landingUrl!;
WeChatImage? remoteWechatImage;
String? thumbnailUrl = shareDataModel.thumbnailUrl;
if (thumbnailUrl != null) {
remoteWechatImage = WeChatImage.network(thumbnailUrl, suffix: ".png");
}
WechatShareUtil.shareWebPageUrl(
webPage,
title: shareDataModel.title ?? title,
description: shareDataModel.description ?? description,
thumbnail: remoteWechatImage ?? thumbnailImage,
scene: shareType == AppShareTo.timeline
? WeChatScene.TIMELINE
: WeChatScene.SESSION,
);
}