open_file 3.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 98

open_file #

pub package

A plug-in that can call native APP to open files with string result in flutter,support iOS(UTI) and android(intent)

Usage #

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

  open_file: ^lastVersion 
  #open_file: ^1.3.0

Example #

import 'package:open_file/open_file.dart';"/sdcard/example.txt");
//"/sdcard/example.txt", type: "text/plain", uti: "public.plain-text");

Support #

android #

            {".3gp",    "video/3gpp"},
            {".apk",    "application/"},
            {".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/"},
            {".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/"},
            {".ogg",    "audio/ogg"},
            {".pdf",    "application/pdf"},
            {".png",    "image/png"},
            {".pps",    "application/"},
            {".ppt",    "application/"},
            {".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/"},
            {".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=""
                    tools:replace="android:resource" />

when Android dependency '' has different version for the compile error, add code below in your /android/build.gradle

subprojects {
    project.configurations.all {
        resolutionStrategy.eachDependency { details ->
            if ( == ''
                    && !'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",    ""},
            {".gif",    "com.compuserve.gif"},
            {".bmp",    ""},
            {".ico",    ""},
            {".doc",    ""},
            {".xls",    ""},
            {".ppt",    "​ppt"},
            {".wav",    "​audio"},
            {".wm",     "​media-wm"},
            {".wmv",    "​media-wmv"},
            {".pdf",    "com.adobe.pdf"}

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 #


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


import 'package:flutter/material.dart';
import 'dart:async';

import 'package:open_file/open_file.dart';

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
  _MyAppState createState() => new _MyAppState();

class _MyAppState extends State<MyApp> {
  String _openResult = 'Unknown';

  Future<void> openFile() async {

    final filePath = '/storage/emulated/0/update.apk';
    final result = await;

    setState(() {
      _openResult = "type=${result.type}  message=${result.message}";


  Widget build(BuildContext context) {
    return new MaterialApp(
      home: new Scaffold(
        appBar: new AppBar(
          title: const Text('Plugin example app'),
        body: Center(
          child: Column(
            children: <Widget>[
              Text('open result: $_openResult\n'),
                child: Text('Tap to open file'),
                onPressed: openFile,

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  open_file: ^3.0.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:open_file/open_file.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jul 12, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux


  • package:open_file/open_file.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos


  • package:open_file/open_file.dart that declares support for platforms: android, ios

Package does not support Flutter platform web


  • package:open_file/open_file.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows


  • package:open_file/open_file.dart that declares support for platforms: android, ios

Package not compatible with SDK dart


  • open_file that is a package requiring null.

Health suggestions

Fix lib/src/plaform/windows.dart. (-1 points)

Analysis of lib/src/plaform/windows.dart reported 2 hints:

line 19 col 5: Name non-constant identifiers using lowerCamelCase.

line 24 col 9: Name non-constant identifiers using lowerCamelCase.

Format lib/open_file.dart.

Run flutter format to format lib/open_file.dart.

Format lib/src/common/open_result.dart.

Run flutter format to format lib/src/common/open_result.dart.

Fix additional 3 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/plaform/linux.dart (Run flutter format to format lib/src/plaform/linux.dart.)
  • lib/src/plaform/macos.dart (Run flutter format to format lib/src/plaform/macos.dart.)
  • lib/src/web/web.dart (Run flutter format to format lib/src/web/web.dart.)


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
ffi ^0.1.3 0.1.3
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety