You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
874 B
Dart
27 lines
874 B
Dart
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);
|
|
}
|