PowerFileView는 DOC, XLS, PPT, TXT 및 PDF를 포함한 여러 파일 형식을 원활하게 볼 수 있도록 해주는 플러터 위젯입니다. 안드로이드에서는 렌더링에 텐센트 X5를 사용하고, iOS에서는 WKWebView를 사용합니다. 이 패키지는 플러터 앱 내에서 파일 미리보기 기능을 쉽게 통합할 수 있게 하며, 최소한의 설정으로 신뢰할 수 있는 크로스플랫폼 지원을 제공합니다. 외부 앱 의존 없이 문서 브라우징이 필요한 애플리케이션에 적합합니다.
ios uses WKWebView, all supported by WKWebView can be previewed
Supported formats
Format
android
ios
.doc
✅
✅
.docx
✅
✅
.ppt
✅
✅
.pptx
✅
✅
.xls
✅
✅
.xlsx
✅
✅
.pdf
✅
✅
Integration
1. Dependency
Add under the pubspec.yaml file:
power_file_view: ^1.0.0
2. Quick integration
1. Android
Since using android to use TBS service, network permission and storage permission are required.
Add the following permissions to the AndroidManifest file of Android.
In order to prevent the release version from failing to load the TBS kernel library.
Add the following code to the obfuscation file proguard-rules.pro.
Since android uses the TBS service, it needs to be initialized before use, which takes about 3-30 seconds.
Asynchronous initialization (recommended)
Asynchronous initialization can be performed under the main function of the app's main.dart file, so that the user does not need to wait for TBS initialization when opening the file.
If the asynchronous initialization configuration is not performed, the initialization operation will be performed automatically before the file is opened, and the user does not need to configure
4. Quick use
file preview
Network files: Just pass in the downloadUrl of the file to be previewed and the downloadPath of the storage path of the file to download.
define downloadPath
import 'package:path_provider/path_provider.dart';
...
final _directory = await getTemporaryDirectory();
final downloadPath = "${_directory.path}/fileview/"fileName.pdf";//Set a name you like
Local file: Just pass in the downloadPath of the path where the local file is located.