open_with_app 0.0.1 copy "open_with_app: ^0.0.1" to clipboard
open_with_app: ^0.0.1 copied to clipboard

A plugin for opening specific file types with your app

open_with_app #

A Flutter plugin that enables your app to handle "Open With" intents from the system file manager or other apps. It supports custom file extensions and allows you to read the content of the file that opened your app.

Demo video

Usage #

final _openWithAppPlugin = OpenWithApp();

// Check if app was opened with a file
String? initialFile = await _openWithAppPlugin.getInitialFile();

// Listen for new files opened while app is running
_openWithAppPlugin.getFileStream().listen((filePath) {
  print("New file: $filePath");
});

Setup #

Android #

Update your android/app/src/main/AndroidManifest.xml to include an intent filter for your custom file extension (e.g., .owa).

<activity ...>
    ...
    <!-- 
       Intent filter for opening files directly (e.g. from File Explorer).
       Required for handling "Open View" intents.
    -->
    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="file" />
        <data android:scheme="content" />
        <data android:mimeType="*/*" />
        <data android:host="*" />
        <data android:pathPattern=".*\\.owa" /> <!-- Change .owa to your extension -->
    </intent-filter>

    <!-- 
       Intent filter for sharing files (e.g. "Share" from another app).
       Optional: Add this if you want your app to appear in the "Share" sheet.
    -->
     <intent-filter>
        <action android:name="android.intent.action.SEND" />
        <category android:name="android.intent.category.DEFAULT" />
        <data android:mimeType="*/*" />
    </intent-filter>
</activity>

iOS #

Update your ios/Runner/Info.plist to register the document type.

<dict>
    ...
    <!-- Add the following keys to your Info.plist -->
    <key>LSSupportsOpeningDocumentsInPlace</key>
    <true/>
    <key>UIFileSharingEnabled</key>
    <true/>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>OWA File</string> <!-- Change to your file type name -->
            <key>CFBundleTypeRole</key>
            <string>Editor</string>
            <key>LSHandlerRank</key>
            <string>Owner</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>dev.wiefel.owa</string> <!-- Change to your identifier -->
            </array>
        </dict>
    </array>
    <key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
            <array>
                <string>public.data</string>
            </array>
            <key>UTTypeDescription</key>
            <string>OWA File</string> <!-- Change to your file description -->
            <key>UTTypeIdentifier</key>
            <string>dev.wiefel.owa</string> <!-- Change to your identifier -->
            <key>UTTypeTagSpecification</key>
            <dict>
                <key>public.filename-extension</key>
                <array>
                    <string>owa</string> <!-- Change to your extension -->
                </array>
            </dict>
        </dict>
    </array>
</dict>
3
likes
160
points
89
downloads

Publisher

verified publisherwiefel.dev

Weekly Downloads

A plugin for opening specific file types with your app

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on open_with_app

Packages that implement open_with_app