Is there a way in Flutter to show the list of installed apps to open a file with that works in IOS/Android?

I'm trying to implement the open with functionality in flutter that allows the user to select the app to open a file with, and that works both in iOS/Android.

enter image description here

The issue I'm facing is that I need to get the installed apps from the device and the plugins I've found don't work in IOS.

These plugins allow me to get installed apps but they only work in Android.

This might work for opening the app but I need the exact name.

Upvotes: 1

Views: 6054

Answers (2)

I think I've already found the answer, the plugin open_file supports both Android and iOS and a variety of file extensions, you only need to specify the path of the file and it will open with the default app, if you have more than one app able to open the file the OS will show the Open With dialog with the apps.

enter image description here

Upvotes: 0

Guillaume Roux
Guillaume Roux

Reputation: 7328

Contrary to Android, Apple does not provide API to get compatible applications. You will need to make the implementation to show the available apps and launch them yourself. Personally I've already done something similar to open other map applications than Apple Plans so it should definitely be possible.

You can check if a specific application is available by using the package url_launcher and its method canLaunch by trying to launch the URL scheme of an application. For example Google Drive has the URL scheme googledrive:// so if I want to check for Google Drive's availability I will need to do as follow:

import 'package:url_launcher/url_launcher.dart';

bool isAvailable = await canLaunch('googledrive://');

And then I can open it by using the same URL scheme with the needed parameters:

import 'package:url_launcher/url_launcher.dart';

await launch('googledrive://docs.google.com/document/<my_document_url>');

But you will need to define yourself all the applications you are supporting in your application and you will have to create the choice modal dynamically in Flutter depending on the available apps.

Upvotes: 4

Related Questions