This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import 'dart:typed_data';
|
||||
import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:open_filex/open_filex.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
Future<void> platformViewPdf(BuildContext context, Uint8List bytes, {required String filename}) async {
|
||||
final dir = await getTemporaryDirectory();
|
||||
final f = File('${dir.path}/$filename');
|
||||
await f.writeAsBytes(bytes);
|
||||
await OpenFilex.open(f.path);
|
||||
}
|
||||
|
||||
Future<void> platformDownloadPdf(Uint8List bytes, {required String filename}) async {
|
||||
final savePath = await FilePicker.platform.saveFile(
|
||||
dialogTitle: 'PDF speichern als',
|
||||
fileName: filename,
|
||||
type: FileType.custom,
|
||||
allowedExtensions: ['pdf'],
|
||||
lockParentWindow: true,
|
||||
);
|
||||
if (savePath == null) return;
|
||||
final f = File(savePath);
|
||||
await f.writeAsBytes(bytes);
|
||||
}
|
||||
Reference in New Issue
Block a user