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

outdated

文件视图,支持本地文件与网络链接

Flutter File View #

Language: English | 中文

At present, the plugin is only used by Android, iOS

You can use FileReaderView to preview local files

You can use FileNetworkView to download the network link and preview the file in combination with FileReaderView

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 <3.0.0"

Flutter

Add flutter_file_view to pubspec.yaml dependencies.

dependencies:
  flutter_file_view:
    git:
      url: 'https://github.com/LiWenHui96/view.git'

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 #

参数名 类型 描述 默认值
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 FileReaderView loading and reduce the jamming
41
likes
0
pub points
89%
popularity

Publisher

unverified uploader

文件视图,支持本地文件与网络链接

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

dio, filesize, flutter, permission_handler

More

Packages that depend on flutter_file_view