11 final dir = await getTemporaryDirectory();
12 final fileName = assetPath.split(
'/').last;
13 final file = File(
'${dir.path}/$fileName');
16 final data = await rootBundle.load(assetPath);
17 final bytes = data.buffer.asUint8List();
18 await file.writeAsBytes(bytes);
21 final result = await OpenFile.open(file.path);
23 if (result.type != ResultType.done) {
24 throw 'Could not open the PDF: ${result.message}';