student-legacy/refilc/lib/helpers/share_helper.dart
2024-06-20 12:06:50 +02:00

19 lines
677 B
Dart

import 'package:refilc/helpers/attachment_helper.dart';
import 'package:refilc_kreta_api/models/attachment.dart';
import 'package:flutter/widgets.dart';
import 'package:share_plus/share_plus.dart';
class ShareHelper {
static Future<void> shareText(String text, {String? subject}) =>
Share.share(text, subject: subject);
static Future<void> shareFile(String path, {String? text, String? subject}) =>
Share.shareXFiles([XFile(path)], text: text, subject: subject);
static Future<void> shareAttachment(Attachment attachment,
{required BuildContext context}) async {
String path = await attachment.download(context);
await shareFile(path);
}
}