share_helper.dart
2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* @Author: 王长春
* @Date: 2022-03-15 15:17:19
* @LastEditors: 王长春
* @LastEditTime: 2022-03-16 19:15:45
* @Description: 分享工具
*/
import 'package:flutter/material.dart';
// import 'package:flutter_wxwork/flutter_wxwork.dart';
import 'package:one_key/utils/repaint_boundary_utils.dart';
// import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:one_key/utils/utils.dart';
import 'package:one_key/utils/wx_sdk.dart';
// import 'package:organization/common/utils/repaintBoundary_utils.dart';
// import 'package:organization/common/utils/wechatSDK.dart';
// import 'package:share_plus/share_plus.dart';
class ShareHelper {
static bool wxIsInstalled = false;
//微信分享截图
static onShareWx(BuildContext context, {boundaryKey}) async {
wxIsInstalled = await WxSdk.wxIsInstalled();
//收回键盘,如果有输入的情况下,先收回键盘,再截图
FocusScope.of(context).requestFocus(FocusNode());
if (wxIsInstalled) {
//分享
// WxSdk.ShareText("sdgsfds",title:"标题");
//获取截图地址
String filePath = await RepaintBoundaryUtils().captureImage(boundaryKey);
print(filePath);
WxSdk.ShareImage(title: "机构检索", decs: "", file: filePath);
} else {
//提示未安装微信
Utils.showToast("未安装微信");
}
}
// static void checkWx() async {
// wxIsInstalled = await WxSdk.wxIsInstalled();
// }
//企业微信分享
// static Future<bool> onShareWxwork(BuildContext context, {boundaryKey}) async {
// FlutterWxwork flutterWxwork = FlutterWxwork();
// bool isAppInstalled = await flutterWxwork.isAppInstalled();
// print(isAppInstalled);
// //收回键盘,如果有输入的情况下,先收回键盘,再截图
// FocusScope.of(context).requestFocus(FocusNode());
// if (isAppInstalled) {
// //分享
// // WxSdk.ShareText("sdgsfds",title:"标题");
// //获取截图地址
// String filePath = await RepaintBoundaryUtils().captureImage(boundaryKey);
// print(filePath);
// await flutterWxwork.registerApp(
// "wwauthbdca186ec4257973000006", "wwbdca186ec4257973", "1000006");
// await flutterWxwork.shareImagePath(filePath);
// } else {
// //提示未安装微信
// Utils.showToast("未安装企业微信");
// }
// }
}