Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
pdf_opener.dart
Go to the documentation of this file.
1import 'dart:io';
2
3import 'package:flutter/services.dart';
4import 'package:open_file/open_file.dart';
5import 'package:path_provider/path_provider.dart';
6
7class PDFOpener {
8 static Future<void> openPDFAsset(String assetPath) async {
9 try {
10 // Get temporary directory
11 final dir = await getTemporaryDirectory();
12 final fileName = assetPath.split('/').last;
13 final file = File('${dir.path}/$fileName');
14
15 // Copy asset to temporary directory
16 final data = await rootBundle.load(assetPath);
17 final bytes = data.buffer.asUint8List();
18 await file.writeAsBytes(bytes);
19
20 // Open the file
21 final result = await OpenFile.open(file.path);
22
23 if (result.type != ResultType.done) {
24 throw 'Could not open the PDF: ${result.message}';
25 }
26 } catch (e) {
27 rethrow;
28 }
29 }
30}
static Future< void > openPDFAsset(String assetPath) async
class Partner String