flutter_file_view 0.1.3 
flutter_file_view: ^0.1.3 copied to clipboard
File view plugin for Flutter, support local file and network link of Android, iOS
Flutter File View #
Language: English | 中文
At present, the plugin is only used by Android, iOS
You can use FileLocalView to preview local files
You can use FileNetworkView to download the network link and
preview the file in combination with FileLocalView
Use of third-party plugins
Use permission_handler to request permission, and use dio to make network requests, and
use filesize to convert the file size
Local File Preview #
Android is implemented by Tencent X5, iOS is implemented by WKWebView.
Supported file type #
- Android 
docx,doc,xlsx,xls,pptx,ppt,pdf,txt - IOS 
docx,doc,xlsx,xls,pptx,ppt,pdf,txt,jpg,jpeg,png 
Preparing for use #
Version constraints
  sdk: ">=2.12.0 <3.0.0"
  flutter: ">=2.0.0"
Flutter
Add flutter_file_view to pubspec.yaml dependencies.
dependencies:
  flutter_file_view: ^latest_version
iOS
Make sure you add the following key to Info.plist for iOS
<key>io.flutter.embedded_views_preview</key><true/>
Android
Android P Unable to download kernel Solution
Add a piece of code in label application on AndroidManifst.xml file
android:networkSecurityConfig="@xml/network_security_config"
Add a file named network_security_config.xml in res/xml directory, The content of the file is
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
</network-security-config>
Usage #
| Name | Type | Description | Default | 
|---|---|---|---|
| filePath | String | 
Local file address (full address) | Required | 
| unSupportPlatformTip | String | 
Platform prompts are not supported | 当前仅支持Android、iOS平台 | 
| nonExistentFileTip | String | 
Prompt that the file does not exist | 文件不存在 | 
| fileFailTip | String | 
File open failed tip | 文件打开失败 | 
| loadingWidget | Widget | 
Loading Widget | See source file | 
| unSupportFileWidget | Widget | 
Unsupported file widget | See source file | 
| noPermissionWidget | Widget | 
No Storage Permission | See source file | 
Android special notes #
- The X5 kernel loading method has been integrated in the plugin
 - Get the current kernel loading status through 
getX5Status() - It can be initialized by itself through 
initX5(). It is mainly used to solve the problem of unsuccessful download 
READ #
- Not Support Google Play, Reason: Issues 1.11
 - Running on Android emulator is not supported
 - If the txt document displays garbled code, please change the txt document code to GBK
 
Network Link View #
A network link view which based on the WeChat’s UI, with download function and view click effect
Usage #
| Name | Type | Description | Default | 
|---|---|---|---|
| fileShowName | String | 
The name of the file displayed on the page | Required | 
| fileType | String | 
The type of file | Required | 
| downloadUrl | String | 
File link to download | Required | 
| downloadPath | String | 
Storage address of downloaded files | Required | 
| onViewPressed | VoidCallback | 
File viewing function | Required | 
| fileNameStyle | TextStyle | 
TextType of fileShowName | 
See source file | 
| downloadTitle | Widget | 
Button title when downloadable | 文件下载 | 
| viewTitle | String | 
Button title when viewable | 文件查看 | 
| btnTitleColor | Color | 
Button title color | Colors.white | 
| btnBgColor | Color | 
Button background color | Theme.of(context).primaryColor | 
| borderSide | BorderSide | 
Button border | ElevatedButton 默认 | 
| cornerRadius | double | 
Button radian | ElevatedButton 默认 | 
Future Plans #
- Optimize the initialization process of Android X5 kernel to reduce the failure rate
 - Implement initialization monitoring of Android X5 kernel
 - Realize online viewing of network links. At present, 
FileNetworkViewcan be used to view after downloading - Optimize the process of 
FileLocalViewloading and reduce the jamming