open_file 3.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 99

open_file #

pub package

可以调用本机APP打开带有字符串的文件的插件会产生抖动,支持iOS(UTI)和android(intent)

Usage #

要使用此插件,请在您的pubspec.yaml文件中添加open_file作为依赖项.

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

Example #

import 'package:open_file/open_file.dart';

OpenFile.open("/sdcard/example.txt");
//OpenFile.open("/sdcard/example.txt", type: "text/plain", uti: "public.plain-text");

Support #

android #

{
            {".3gp",    "video/3gpp"},
            {".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"},
            {"",        "*/*"}
}

当与与FileProvider的其他插件冲突时,在/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>

当Android依赖项" com.android.support:appcompat-v7"具有不同版本的编译错误时,请在/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 #

{
            {".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.0.1 #

  • 修正网页参数错误
  • 将结果值从String替换为OpenResult.

3.0.0 #

  • 更新到了v2 Android插件API
  • 识别android错误(未找到APP和其他)
  • 添加网络支持
  • 添加电脑支持

2.1.1 #

  • 回滚2.0.3

2.1.0-pre.1 #

  • 添加网络支持(测试版)
  • 添加PC支持(测试版)

2.0.3 #

  • 将使用FileProvider从Android M更改为Android N

2.0.2 #

  • 捕获没有发现活动来处理意图异常
  • 优化对Android O的请求REQUEST_INSTALL_PACKAGES权限

2.0.1+2 #

  • 修复Android M FLAG_GRANT_READ_URI_PERMISSION

2.0.1+1 #

  • 修复了由第三方插件请求权限导致的崩溃

2.0.1 #

  • 迁移到androidx

1.3.0 #

  • 回滚支持

1.2.3+1 #

  • 当文件不在应用程序目录中时,请求READ_EXTERNAL_STORAGE

1.2.3 #

  • 在Android上优化权限请求逻辑

1.2.2+2 #

  • 修复requestPermission时崩溃

1.2.2+1 #

  • 迁移到androidx

1.2.2 #

  • 必要时寻求许可

1.2.1 #

  • 修理东西

1.2.0 #

  • 添加自定义参数,"类型" android," uti" iOS

1.1.1 #

  • 修复android中的startActivity崩溃

1.1.0 #

  • 修复ios打开文件

1.0.7 #

  • 解决与有关FileProvider和multi appcompat-v7的其他插件的冲突

1.0.6 #

  • 解决与image_provider插件的冲突

1.0.5 #

  • 只需支持> = 2.0.0-dev.28.0

1.0.4 #

  • 只支持Dart2

1.0.3 #

  • 只支持Dart2

1.0.2 #

  • 新增了iOS支持并支持android 7.0或更高版本

example/README.md

open_file #

可以为Android打开文件的插件

Usage #

要使用此插件,请在您的pubspec.yaml文件中添加open_file作为依赖项.

Example #

import 'package:open_file/open_file.dart';

OpenFile.open("/sdcard/text.txt");

Support #

{
            {".3gp",    "video/3gpp"},
            {".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"},
            {"",        "*/*"}
};

Use this package as a library

1. Depend on it

将此添加到包的pubspec.yaml文件中:


dependencies:
  open_file: ^3.0.1

2. Install it

您可以从命令行安装软件包:

使用Flutter:


$ flutter pub get

另外,您的编辑器可能支持flutter pub get . 查看您的编辑器文档以了解更多信息.

3. Import it

现在,在Dart代码中,您可以使用:


import 'package:open_file/open_file.dart';
  
Popularity:
描述该程序包相对于其他程序包的受欢迎程度. [更多]
98
Health:
从静态分析得出的代码运行状况. [更多]
99
Maintenance:
反映出软件包的整洁和最新状态. [更多]
100
Overall:
以上的加权分数. [更多]
99
了解有关得分的更多信息.

我们在2020年1月21日对该程序包进行了分析,并在下面提供了得分,详细信息和建议. using: 分析已完成,状态使用以下命令 :

  • 飞镖:2.7.0
  • 高达:0.13.4
  • Flutter:1.12.13 + hotfix.5

Health suggestions

修复lib/src/plaform/windows.dart . (-1分)

分析lib/src/plaform/windows.dart报告了2条提示:

第19行第5行:使用lowerCamelCase命名非常数标识符.

第24行第9行:使用lowerCamelCase命名非常数标识符.

Format lib/open_file.dart.

运行flutter format以格式化lib/open_file.dart .

Format lib/src/common/open_result.dart.

运行flutter format以格式化lib/src/common/open_result.dart .

修复具有分析或格式问题的其他3个文件.

以下文件中的其他问题:

  • lib/src/plaform/linux.dart (运行flutter format以格式化lib/src/plaform/linux.dart .)
  • lib/src/plaform/macos.dart (运行flutter format以格式化lib/src/plaform/macos.dart .)
  • lib/src/web/web.dart (运行flutter format以格式化lib/src/web/web.dart .)

Dependencies

Package Constraint Resolved Available
直接依赖
Dart SDK > = 2.1.0 <3.0.0
ffi ^0.1.3 0.1.3
flutter 0.0.0
传递依存关系
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8

by  ICOPY.SITE