mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-27 05:59:38 +00:00
37ef63d09e
* Add exception handler to anypay api response failure * Check if context is still mounted before fetching iPad position * Add user connection issue to ignored errors * Wrap launchURL in empty try catch to avoid package un-needed exceptions
40 lines
951 B
Dart
40 lines
951 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:share_plus/share_plus.dart';
|
|
import 'package:cross_file/cross_file.dart';
|
|
|
|
class ShareUtil {
|
|
static void share({required String text, required BuildContext context}) {
|
|
Share.share(
|
|
text,
|
|
sharePositionOrigin: _sharePosition(context),
|
|
);
|
|
}
|
|
|
|
static Future<void> shareFile({
|
|
required String filePath,
|
|
required String fileName,
|
|
required BuildContext context,
|
|
}) async {
|
|
const _mimeType = 'application/*';
|
|
await Share.shareXFiles(
|
|
<XFile>[
|
|
XFile(
|
|
filePath,
|
|
name: fileName,
|
|
mimeType: _mimeType,
|
|
)
|
|
],
|
|
sharePositionOrigin: _sharePosition(context),
|
|
);
|
|
}
|
|
|
|
static Rect _sharePosition(BuildContext context) {
|
|
if (!context.mounted) {
|
|
return Rect.zero;
|
|
}
|
|
|
|
final box = context.findRenderObject() as RenderBox?;
|
|
|
|
return box!.localToGlobal(Offset.zero) & box.size;
|
|
}
|
|
}
|