flutter_file_view 1.0.1 copy "flutter_file_view: ^1.0.1" to clipboard
flutter_file_view: ^1.0.1 copied to clipboard

outdated

File view plugin for Flutter, support local file and network link of Android, iOS

Flutter File View #

pub package

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 dio to make network requests, The v1.0.0 version no longer provides permission requests.

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.14.0 <3.0.0"
  flutter: ">=2.5.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 #

  1. The X5 kernel loading method has been integrated in the plugin
  2. Get the current kernel loading status through getX5Status()
  3. It can be initialized by itself through initX5(). It is mainly used to solve the problem of unsuccessful download

READ #

  1. Not Support Google Play, Reason: Issues 1.11
  2. Running on Android emulator is not supported
  3. 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, FileNetworkView can be used to view after downloading
  • Optimize the process of FileLocalView loading and reduce the jamming
45
likes
0
pub points
88%
popularity

Publisher

unverified uploader

File view plugin for Flutter, support local file and network link of Android, iOS

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter

More

Packages that depend on flutter_file_view