パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v4.0.5

open_app_file

アプリがアクセス権を持つファイルを、システムによって提供されるデフォルトのアプリケーションで開くためのプラグインです。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
8550
いいね数
30
Pub ポイント
150

パッケージをインストール

flutter pub add open_app_file

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

アプリがアクセスできるファイルをシステムのデフォルトアプリケーションで開くことを可能にするFlutterプラグインです。Android、iOS、Web、macOS、Windows、Linuxでのクロスプラットフォームファイル起動をサポートしており、プラットフォーム固有のコードを書かずにアプリにファイル開き機能を簡単に統合できます。このプラグインは、アプリのディレクトリにあるファイルや、ファイルピッカー経由で選択されたファイルなど、アプリがアクセス権を持つファイルと連携します。

用途

  • ダウンロードした文書を開く
  • 画像またはPDFの起動
  • ネイティブアプリとファイルを共有する
  • ファイルプレビューの統合
  • ユーザー主導のファイル操作を有効にする

主な機能

  • クロスプラットフォーム互換性
  • システムのデフォルトアプリを使用
  • すべての主要なオペレーティングシステムをサポートしています
  • ファイルを開くためのシンプルな API
  • 付与された権限を介した安全なファイルアクセス

適している対象

  • ファイル管理アプリ
  • ドキュメントビューア
  • メディアプレーヤー
  • 生産性ツール
  • ファイル共有を必要とするアプリ

注意事項

  • 適切なファイル権限が必要です
  • アプリがアクセスできるファイルに限定
  • プラットフォーム固有の動作は異なる場合があります
  • ファイル作成を処理しない
  • Web サポートはブラウザの機能に依存します

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

open_file

pub package

A plugin to open files the app has permission to access with default system-provided applications.

Supports Android, iOS, Web, Linux, macOS and Windows.

Fork info

The library is forked from open_file by crazecoder

This version:

  • does not include REQUEST_INSTALL_PACKAGES permission on Android, so cannot install .apk's
  • does not include READ_EXTERNAL_STORAGE permission on Android
  • has completely rewritten Android implementation for more robust permission checks
  • has deprecated explicit list of MIME types, UTI's, and Linux launch options
  • web implementation is changed (see below)

The main use case for the plugin is opening a generated or downloaded file with a default system application (see example).

Usage

Add open_file as a dependency in your pubspec.yaml file.

dependencies:
  open_app_file: ^lastVersion

Example

import 'package:open_app_file/open_app_file.dart';

OpenAppFile.open('/sdcard/example.txt');

// You can provide overrides for MIME type (Android) and/or UTI (iOS). This is not necessary
// in most cases, but if you know that the file extension does not match its content, you can
// help the system to provide correct response to your request.
OpenAppFile.open('/sdcard/example.abc', mimeType: 'text/plain', uti: 'public.plain-text');

Behavior on Android

While the main purpose of the plugin is opening files owned by the host app, it is possible to open any file even considering Android 11 scoped storage limitations (see official docs). The plugin will not provide any tools for requesting permissions to prevent declaring them in the Manifest for apps that don't need to handle this case. An attempt to open a file with no permissions granted will produce an appropriate result (ResultType.permissionDenied).

See more details and instructions on how to test permission conditions in the example app.

Behavior on web

Direct local file access is generally discouraged on web, therefore we chose the approach that in most cases is the most logical web alternative: imitate user clicking on an element that targets the requested file. For most files it will result in browser downloading the requested file immediately. Some file types, like images, texts, or videos might be opened directly, so the library adds target: _blank attribute to prevent user from leaving the application by accident.

The important limitation of this approach is that there's no way to check file type or availability beforehand, so on web the open call always succeeds.

Check the example app for general idea on how app-generated or remote files can be handled on web.

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト