import 'dart:io';
|
|
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/services.dart';
|
import 'package:share_plus/share_plus.dart';
|
|
import 'config_util.dart';
|
|
class ShareUtil {
|
static shareImg(
|
BuildContext context, File f, SharePlatform sharePlatform) async {
|
if (Platform.isAndroid) {
|
const platform = MethodChannel("com.yeshi.location/share"); //分析1
|
bool result = false;
|
try {
|
var params = {
|
"path": f.path,
|
"platform": sharePlatform.runtimeType.toString()
|
};
|
switch (sharePlatform) {
|
case SharePlatform.qq:
|
params["platform"] = "qq";
|
break;
|
case SharePlatform.wx:
|
params["platform"] = "wx";
|
break;
|
case SharePlatform.sina:
|
params["platform"] = "sina";
|
break;
|
}
|
|
result = await platform.invokeMethod("shareImg", params); //分析2
|
} on PlatformException catch (e) {
|
print(e.toString());
|
}
|
} else {
|
Share.shareFiles([f.path]);
|
}
|
}
|
}
|