用户可在 Flutter 应用中跨平台预览多种文档格式。Android 集成腾讯浏览服务内核,iOS 基于 WKWebView,支持在线文件缓存,支持 doc、docx、pdf 等主流格式及回调监听。【此简介由AI生成】
当前项目代码仓暂无内容
file_preview
本项目基于 file_preview 开发。
1. 安装与使用
1.1 安装方式
进入到工程目录并在 pubspec.yaml 中添加以下依赖:
pubspec.yaml
...
dependencies:
file_preview:
git:
url: https://gitcode.com/openharmony-sig/fluttertpc_file_preview.git
path: ohos
...
执行命令
flutter pub get
1.2 使用案例
使用案例详见 ohos/example。
2. 约束与限制
2.1 兼容性
在以下版本中已测试通过
- Flutter: 3.7.12-ohos-1.1.3; SDK: 5.0.0(12); IDE: DevEco Studio: 5.1.0.828; ROM: 5.1.0.130 SP8;
- Flutter: 3.22.1-ohos-1.0.3; SDK: 5.0.0(12); IDE: DevEco Studio: 5.1.0.828; ROM: 5.1.0.130 SP8;
3. API
"ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
| Name | Description | Type | Input | Output | ohos Support |
|---|---|---|---|---|---|
| initTBS | TBS初始化 | function | required String license | Future | no |
| tbsHasInit | 判断TBS是否已经初始化 | function | / | Future | no |
| deleteCache | 删除本地缓存 | function | / | Future | no |
| tbsVersion | 获取TBS版本 | function | / | Future | no |
| showFile | 切换文件 | function | String path | void | yes |
4. 属性
"ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
Parameters
| Name | Description | Type | ohos Support |
|---|---|---|---|
| path | 文件地址 https/http开头、文件格式结尾的地址,或者本地绝对路径 | String | yes |
5. 遗留问题
6. 其他
7. 开源协议
本项目基于 Apache-2.0 ,请自由地享受和参与开源。