open_file

v3.5.11

A plug-in that can call native APP to open files with string result in flutter, support iOS(UTI) / android(intent) / PC(ffi) / web(dart:html)

Архив пакета: https://pubdev.letsnova.ru/api/archives/open_file/3.5.11.tar.gz

Установкаdart pub add open_file

README

open_file

pub package

A plug-in that can call native APP to open files with string result in flutter, support iOS(DocumentInteraction) / android(intent) / PC(ffi) / web(dart:html)

Usage

To use this plugin, add open_file as a dependency in your pubspec.yaml file.

If you want to open an external file, You need to request permission start in 3.3.0, This is an example

dependencies:
                  #androidx
                  open_file: ^lastVersion 
                  #support
                  #open_file: ^1.3.0
                

Example

import 'package:open_file/open_file.dart';
                
                OpenFile.open("/sdcard/example.txt");
                
                //Support for custom add types
                const types = {
                  ".pdf": "application/pdf",
                  ".dwg": "application/x-autocad"
                };
                _openOtherTypeFile() async {
                  final filePath = "/sdcard/Download/R-C.dwg";
                  final extension = path.extension(filePath);//import 'package:path/path.dart' as path;
                  await OpenFile.open(filePath, type: types[extension]);
                }
                //OpenFile.open("/sdcard/example.txt", type: "text/plain", uti: "public.plain-text");
                

Support

android

{
                            {".3gp",    "video/3gpp"},
                            {".torrent","application/x-bittorrent"},
                            {".kml",    "application/vnd.google-earth.kml+xml"},
                            {".gpx",    "application/gpx+xml"},
                            {".csv",    "application/vnd.ms-excel"},
                            {".apk",    "application/vnd.android.package-archive"},
                            {".asf",    "video/x-ms-asf"},
                            {".avi",    "video/x-msvideo"},
                            {".bin",    "application/octet-stream"},
                            {".bmp",    "image/bmp"},
                            {".c",      "text/plain"},
                            {".class",  "application/octet-stream"},
                            {".conf",   "text/plain"},
                            {".cpp",    "text/plain"},
                            {".doc",    "application/msword"},
                            {".docx",   "application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
                            {".xls",    "application/vnd.ms-excel"},
                            {".xlsx",   "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
                            {".exe",    "application/octet-stream"},
                            {".gif",    "image/gif"},
                            {".gtar",   "application/x-gtar"},
                            {".gz",     "application/x-gzip"},
                            {".h",      "text/plain"},
                            {".htm",    "text/html"},
                            {".html",   "text/html"},
                            {".jar",    "application/java-archive"},
                            {".java",   "text/plain"},
                            {".jpeg",   "image/jpeg"},
                            {".jpg",    "image/jpeg"},
                            {".js",     "application/x-javascript"},
                            {".log",    "text/plain"},
                            {".m3u",    "audio/x-mpegurl"},
                            {".m4a",    "audio/mp4a-latm"},
                            {".m4b",    "audio/mp4a-latm"},
                            {".m4p",    "audio/mp4a-latm"},
                            {".m4u",    "video/vnd.mpegurl"},
                            {".m4v",    "video/x-m4v"},
                            {".mov",    "video/quicktime"},
                            {".mp2",    "audio/x-mpeg"},
                            {".mp3",    "audio/x-mpeg"},
                            {".mp4",    "video/mp4"},
                            {".mpc",    "application/vnd.mpohun.certificate"},
                            {".mpe",    "video/mpeg"},
                            {".mpeg",   "video/mpeg"},
                            {".mpg",    "video/mpeg"},
                            {".mpg4",   "video/mp4"},
                            {".mpga",   "audio/mpeg"},
                            {".msg",    "application/vnd.ms-outlook"},
                            {".ogg",    "audio/ogg"},
                            {".pdf",    "application/pdf"},
                            {".png",    "image/png"},
                            {".pps",    "application/vnd.ms-powerpoint"},
                            {".ppt",    "application/vnd.ms-powerpoint"},
                            {".pptx",   "application/vnd.openxmlformats-officedocument.presentationml.presentation"},
                            {".prop",   "text/plain"},
                            {".rc",     "text/plain"},
                            {".rmvb",   "audio/x-pn-realaudio"},
                            {".rtf",    "application/rtf"},
                            {".sh",     "text/plain"},
                            {".tar",    "application/x-tar"},
                            {".tgz",    "application/x-compressed"},
                            {".txt",    "text/plain"},
                            {".wav",    "audio/x-wav"},
                            {".wma",    "audio/x-ms-wma"},
                            {".wmv",    "audio/x-ms-wmv"},
                            {".wps",    "application/vnd.ms-works"},
                            {".xml",    "text/plain"},
                            {".z",      "application/x-compress"},
                            {".zip",    "application/x-zip-compressed"},
                            {"",        "*/*"}
                }
                
                

when Conflict with other plugins about FileProvider, add code below in your /android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
                          xmlns:tools="http://schemas.android.com/tools"
                          package="xxx.xxx.xxxxx">
                    <application>
                        ...
                        <provider
                                android:name="androidx.core.content.FileProvider"
                                android:authorities="${applicationId}.fileProvider"
                                android:exported="false"
                                android:grantUriPermissions="true"
                                tools:replace="android:authorities">
                            <meta-data
                                    android:name="android.support.FILE_PROVIDER_PATHS"
                                    android:resource="@xml/filepaths"
                                    tools:replace="android:resource" />
                        </provider>
                    </application>
                </manifest>
                

when Android dependency 'com.android.support:appcompat-v7' has different version for the compile error, add code below in your /android/build.gradle

subprojects {
                    project.configurations.all {
                        resolutionStrategy.eachDependency { details ->
                            if (details.requested.group == 'com.android.support'
                                    && !details.requested.name.contains('multidex') ) {
                                details.useVersion "27.1.1"
                            }
                        }
                    }
                }
                

IOS with UTI (DocumentInteraction Auto)

{
                            {".rtf",    "public.rtf"},
                            {".txt",    "public.plain-text"},
                            {".html",   "public.html"},
                            {".htm",    "public.html"},
                            {".xml",    "public.xml"},
                            {".tar",    "public.tar-archive"},
                            {".gz",     "org.gnu.gnu-zip-archive"},
                            {".gzip",   "org.gnu.gnu-zip-archive"},
                            {".tgz",    "org.gnu.gnu-zip-tar-archive"},
                            {".jpg",    "public.jpeg"},
                            {".jpeg",   "public.jpeg"},
                            {".png",    "public.png"},
                            {".avi",    "public.avi"},
                            {".mpg",    "public.mpeg"},
                            {".mpeg",   "public.mpeg"},
                            {".mp4",    "public.mpeg-4"},
                            {".3gpp",   "public.3gpp"},
                            {".3gp",    "public.3gpp"},
                            {".mp3",    "public.mp3"},
                            {".zip",    "com.pkware.zip-archive"},
                            {".gif",    "com.compuserve.gif"},
                            {".bmp",    "com.microsoft.bmp"},
                            {".ico",    "com.microsoft.ico"},
                            {".doc",    "com.microsoft.word.doc"},
                            {".xls",    "com.microsoft.excel.xls"},
                            {".ppt",    "com.microsoft.powerpoint.​ppt"},
                            {".wav",    "com.microsoft.waveform-​audio"},
                            {".wm",     "com.microsoft.windows-​media-wm"},
                            {".wmv",    "com.microsoft.windows-​media-wmv"},
                            {".pdf",    "com.adobe.pdf"}
                }
                

История изменений

3.5.11

  • [IOS] Fix compatibility with UIScene (thanks to @amake)
  • [IOS] Add SPM support (thanks to @vicajilau)
  • [MacOS] Add SPM support

3.5.10

  • [MacOS] Optimized code and fix #312

3.5.9

3.5.8

  • [Android] use canonicalPath instead of path
  • [Android] use checkUriPermission to check whether the file has permission to open

3.5.7

3.5.6

3.5.5

3.5.4

3.5.3

  • remove uti, DocumentInteraction Auto on iOS.
  • remove webData, only open files in the project directory on the web
  • add isIOSAppOpen Whether to use the app to open on iOS.

3.5.2

  • update open_file_ios: ^1.0.1 replace presentOpenInMenuFromRect with presentViewController
  • update open_file_android: ^1.0.1 to fix #245

3.5.1

  • update open_file_linux: ^0.0.3 to fix #291

3.5.0+1

  • linuxByProcess defaults to true #156

3.5.0

  • Utilize the new platform_interface package.
  • Updates minimum Flutter version to 1.20.0.
  • add @visibleForTesting to some methods
  • fix #289

3.4.0

  • Optimized the logical judgment of permission requests for each android version
  • update ffi to 2.1.3
  • AGP 8 namespace issue fix (thanks to @prataptej)
  • add linuxUseGio parameter (thanks to @brainwo)

3.3.2

  • Optimized the logic for determining the cache/files directory for android applications
  • add a conditional judgment for PackageManager.queryIntentActivities
  • update ffi to 2.0.2

3.3.1

  • Refine the media permissions for Android13
  • Add an example of full use

3.3.0

  • Remove the code of permission on Android, If you want to open an external file, You need to request permission

3.2.2

  • FFi updated to v2.
  • android migrated from v1 to v2,
  • folder name corrected, plaform -> platform.
  • package version updated to 3.2.2
  • Gradle updated to gradle-7.3.1

3.2.1

  • Add command parser before create system call #144 (thanks to @mludovico)
  • Fix startActivity() might have NPE issue with filePath on Android (thanks to @AlexV525)
  • Add error type return when file path is nil on iOS

3.2.0

  • add csv/kml/gpx/torrent support on Android
  • remove android:requestLegacyExternalStorage
  • fix Deprecated API warning when build on Android
  • delete uti, DocumentInteraction will be retrieved automatically on iOS (thanks to @std-c)
  • fix returns wrong reponse on Windows

3.1.0

  • upgrade FFI 1.0.0 (thanks to @mit-mit)
  • add linuxByProcess parameter (thanks to @mx1up)
  • Migrate to Dart null safety system (thanks to @orevial)

3.0.3

  • upgrade compileSdkVersion

3.0.2

  • add storage compatibility mode for AndroidQ.
  • fix #106 #100 #74
  • fix multiple file providers. (thanks to @jawa0919)
  • Take file extension in lowercase for comparison.(thanks to @kluverua)
  • Fixed a typo in the error message for fileNotFound.(thanks to @sebas642)

3.0.1

  • fix web parameter error
  • Replace result value from String to OpenResult.

3.0.0

  • updated to the v2 Android Plugin APIs
  • Distinguish android errors (No APP found and others)
  • add web support
  • add pc support

2.1.1

  • rollback 2.0.3

2.1.0-pre.1

  • add web support(beta)
  • add pc support(beta)

2.0.3

  • change use FileProvider from Android M to Android N

2.0.2

  • catch No Activity found to handle Intent exception
  • Optimize request REQUEST_INSTALL_PACKAGES permission on Android O

2.0.1+2

  • fix android M FLAG_GRANT_READ_URI_PERMISSION

2.0.1+1

  • Fixed crash caused by third party plug-in request permissions

2.0.1

  • migrate to androidx

1.3.0

  • roll back support

1.2.3+1

  • request READ_EXTERNAL_STORAGE when the file is not in the app directory

1.2.3

  • Optimize permission request logic on android

1.2.2+2

  • fix crash when requestPermission

1.2.2+1

  • migrate to androidx

1.2.2

  • ask for permission when needed

1.2.1

  • fix somethings

1.2.0

  • Add custom parameters,"type" android,"uti" iOS

1.1.1

  • fix startActivity crash in android

1.1.0

  • fix ios open file

1.0.7

  • resolve conflict with other plugins about FileProvider and multi appcompat-v7 compile

1.0.6

  • resolve conflict with image_provider plugin

1.0.5

  • Just Support >=2.0.0-dev.28.0

1.0.4

  • Just Support Dart2

1.0.3

  • Just Support Dart2

1.0.2

  • Ios Support added and support android 7.0 or above