This commit is contained in:
wyf
2025-05-21 09:53:32 +08:00
parent 0a8cffa4c6
commit 489e907e00
26 changed files with 516 additions and 853 deletions

View File

@@ -1,24 +0,0 @@
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:path/path.dart' as p;
import 'package:path_provider/path_provider.dart';
class PdfController extends GetxController {
var localPdfPath = Rx<String?>(null);
// 加载 PDF 文件
Future<void> loadPdf() async {
final byteData = await rootBundle.load('assets/img/test.pdf');
final tempDir = await getTemporaryDirectory();
// 使用 path 包拼接路径
final filePath = p.join(tempDir.path, 'test.pdf');
final file = File(filePath);
// 保存文件到临时目录
await file.writeAsBytes(byteData.buffer.asUint8List());
localPdfPath.value = filePath; // 更新 PDF 路径
}
}