share_helper.dart 1.39 KB
/*
 * @Author: 王长春
 * @Date: 2022-03-15 15:17:19
 * @LastEditors: 王长春
 * @LastEditTime: 2022-03-16 19:15:45
 * @Description: 分享工具
 */

import 'package:flutter/material.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 Future<bool> 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();
  // }

}