A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.

Overview

Flutter AppAvailability Plugin

Pub

A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.

This plugin was inspired by the plugin AppAvailability for Cordova.

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Installation

First, add flutter_appavailability as a dependency in your pubspec.yaml file.

Methods available

  • checkAvailability(String uri)
  • getInstalledApps() (only for Android)
  • isAppEnabled(String uri) (only for Android)
  • launchApp(String uri)

See the docs.

Example

Here is a small example flutter app displaying a list of installed apps that you can launch.

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

import 'package:flutter_appavailability/flutter_appavailability.dart';

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

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

class _MyAppState extends State<MyApp> {

  List<Map<String, String>> installedApps;
  List<Map<String, String>> iOSApps = [
    {
      "app_name": "Calendar",
      "package_name": "calshow://"
    },
    {
      "app_name": "Facebook",
      "package_name": "fb://"
    },
    {
      "app_name": "Whatsapp",
      "package_name": "whatsapp://"
    }
  ];


  @override
  void initState() {
    super.initState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> getApps() async {
    List<Map<String, String>> _installedApps;

    if (Platform.isAndroid) {

      _installedApps = await AppAvailability.getInstalledApps();

      print(await AppAvailability.checkAvailability("com.android.chrome"));
      // Returns: Map<String, String>{app_name: Chrome, package_name: com.android.chrome, versionCode: null, version_name: 55.0.2883.91}

      print(await AppAvailability.isAppEnabled("com.android.chrome"));
      // Returns: true

    }
    else if (Platform.isIOS) {
      // iOS doesn't allow to get installed apps.
      _installedApps = iOSApps;

      print(await AppAvailability.checkAvailability("calshow://"));
      // Returns: Map<String, String>{app_name: , package_name: calshow://, versionCode: , version_name: }

    }

    setState(() {
      installedApps = _installedApps;
    });

  }

  @override
  Widget build(BuildContext context) {
    if (installedApps == null)
      getApps();

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin flutter_appavailability app'),
        ),
        body: ListView.builder(
          itemCount: installedApps == null ? 0 : installedApps.length,
          itemBuilder: (context, index) {
            return ListTile(
              title: Text(installedApps[index]["app_name"]),
              trailing: IconButton(
                icon: const Icon(Icons.open_in_new),
                onPressed: () {
                  Scaffold.of(context).hideCurrentSnackBar();
                  AppAvailability.launchApp(installedApps[index]["package_name"]).then((_) {
                    print("App ${installedApps[index]["app_name"]} launched!");
                  }).catchError((err) {
                    Scaffold.of(context).showSnackBar(SnackBar(
                        content: Text("App ${installedApps[index]["app_name"]} not found!")
                    ));
                    print(err);
                  });
                }
              ),
            );
          },
        ),
      ),
    );
  }
}

Android: screenshot_1536780581

iOS: simulator screen shot - iphone x - 2018-09-12 at 21 27 05

Comments
  • Migrate to null-safety

    Migrate to null-safety

    Starting pull request to migrate package to null safety version.

    To do:

    • [x] Migrate to null safety;
    • [x] Test in IOS plataform;
    • [x] Test in Android plataform.
    opened by LeonardoRosaa 9
  • deprecated version of the Android embedding

    deprecated version of the Android embedding

    After upgrading Flutter to version 2.5.0 I get the following warning.

    The plugin `flutter_appavailability` uses a deprecated version of the Android embedding.
    To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
    If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.
    

    Could you please updated this plugin?

    opened by CaptainDario 5
  • Can't open my app from background

    Can't open my app from background

    I am trying to implement alarm clock, using alarm manager and this package, but it gives me this message, when i trying to launch app from background:

    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): Failed to handle method call
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.getAppPackageInfo(AppAvailability.java:93)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.launchApp(AppAvailability.java:131)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.onMethodCall(AppAvailability.java:57)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at android.os.MessageQueue.nativePollOnce(Native Method)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at android.os.MessageQueue.next(MessageQueue.java:335)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at android.os.Looper.loop(Looper.java:183)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at android.app.ActivityThread.main(ActivityThread.java:7656)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at java.lang.reflect.Method.invoke(Native Method)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
    E/flutter ( 4567): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
    E/flutter ( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.getAppPackageInfo(AppAvailability.java:93)
    E/flutter ( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.launchApp(AppAvailability.java:131)
    E/flutter ( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.onMethodCall(AppAvailability.java:57)
    E/flutter ( 4567): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
    E/flutter ( 4567): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
    E/flutter ( 4567): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
    E/flutter ( 4567): 	at android.os.MessageQueue.nativePollOnce(Native Method)
    E/flutter ( 4567): 	at android.os.MessageQueue.next(MessageQueue.java:335)
    E/flutter ( 4567): 	at android.os.Looper.loop(Looper.java:183)
    E/flutter ( 4567): 	at android.app.ActivityThread.main(ActivityThread.java:7656)
    
    
    opened by spacekestrel 0
  • Crash when using with Android embedding V2

    Crash when using with Android embedding V2

    We have upgraded our app to support Android Embedding V2. The app attempts to launch and then immediately crashes:

    2021-05-07 14:53:51.474 9171-9171/org.my.app E/MethodChannel#: Parameter messenger must not be null. 2021-05-07 14:53:51.474 9171-9171/org.my.app D/AndroidRuntime: Shutting down VM 2021-05-07 14:53:51.480 9171-9171/org.my.app E/AndroidRuntime: FATAL EXCEPTION: main Process: org.my.app, PID: 9171 java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.BinaryMessenger.setMessageHandler(java.lang.String, io.flutter.plugin.common.BinaryMessenger$BinaryMessageHandler)' on a null object reference at io.flutter.plugin.common.MethodChannel.setMethodCallHandler(MethodChannel.java:119) at com.pichillilorenzo.flutter_appavailability.AppAvailability.registerWith(AppAvailability.java:37) at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:24) at org.my.app.MainActivity.configureFlutterEngine(MainActivity.kt:54) at io.flutter.embedding.android.FlutterFragment.configureFlutterEngine(FlutterFragment.java:1016) at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:180) at io.flutter.embedding.android.FlutterFragment.onAttach(FlutterFragment.java:608) at androidx.fragment.app.Fragment.performAttach(Fragment.java:2672) at androidx.fragment.app.FragmentStateManager.attach(FragmentStateManager.java:253) at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1168) at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1255) at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1138) at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:136) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1987) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1945) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1847) at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2621) at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2569) at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247) at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541) at org.my.app.MainActivity.onStart(MainActivity.kt:178) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1413) at android.app.Activity.performStart(Activity.java:7169) at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3155) at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180) at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165) at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1986) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:215) at android.app.ActivityThread.main(ActivityThread.java:6939) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)

    opened by schricb 1
  • cannot open instagram , youtube , twitter in ios

    cannot open instagram , youtube , twitter in ios

    hi i tried to open instagram,youtube,twitter via "instagram://" and "instagram-stories://"

    see :https://pureoxygenlabs.com/10-app-url-schemes-for-marketers/ and i failed the only working solution is 'whatsapp://'

    any help

    flutter version : Flutter 1.22.3 • channel stable phone : iphone 5s running ios 12.5.1 `[✓] Flutter (Channel stable, 1.22.3, on Mac OS X 10.14.6 18G7016, locale en-EG)

    [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 11.3.1) [✓] Android Studio (version 3.6) [✓] VS Code (version 1.52.1) [✓] Connected device (1 available)

    • No issues found!` any help with ios

    opened by mohadel92 0
Owner
Lorenzo Pichilli
I'm a Heroku Architecture Designer and a Software Engineer mostly focused on Web (FullStack) and Mobile Development. JavaScript, TypeScript & Flutter 💙.
Lorenzo Pichilli
A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.

Flutter InAppWebView Plugin A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser windo

Lorenzo Pichilli 2.3k Jan 8, 2023
Community WebView Plugin - Allows Flutter to communicate with a native WebView.

NOTICE We are working closely with the Flutter Team to integrate all the Community Plugin features in the Official WebView Plugin. We will try our bes

Flutter Community 1.4k Jan 7, 2023
Use dynamic and beautiful card view pagers to help you create great apps.

Use dynamic and beautiful card view pagers to help you create great apps. Preview New Feature v1.3.0 Change Alignment Left Center(Default) Right v1.4.

Jeongtae Kim 84 Dec 6, 2022
Flutter Downloader - A plugin for creating and managing download tasks. Supports iOS and Android. Maintainer: @hnvn

Flutter Downloader A plugin for creating and managing download tasks. Supports iOS and Android. This plugin is based on WorkManager in Android and NSU

Flutter Community 789 Jan 3, 2023
Plugin to retrieve a persistent UDID across app reinstalls on iOS and Android.

flutter_udid Plugin to retrieve a persistent UDID across app reinstalls on iOS and Android. Getting Started import 'package:flutter_udid/flutter_udid.

Leon Kukuk 183 Dec 21, 2022
File picker plugin for Flutter, compatible with both iOS & Android and desktop (go-flutter).

File Picker A package that allows you to use the native file explorer to pick single or multiple files, with extensions filtering support. Currently s

Miguel Ruivo 985 Jan 5, 2023
A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.

Flutter Location Plugin This plugin for Flutter handles getting location on Android and iOS. It also provides callbacks when location is changed. Gett

Guillaume Bernos 953 Dec 22, 2022
Flutter geolocation plugin for Android and iOS.

geolocation Flutter geolocation plugin for Android API 16+ and iOS 9+. Features: Manual and automatic location permission management Current one-shot

Loup 221 Dec 27, 2022
A Flutter plugin for displaying local notifications on Android, iOS and macOS

Flutter Local Notifications plugin This repository consists hosts the following packages flutter_local_notifications: code for the cross-platform faci

Michael Bui 2.1k Dec 30, 2022
Android and iOS Geolocation plugin for Flutter

Flutter Geolocator Plugin A Flutter geolocation plugin which provides easy access to platform specific location services (FusedLocationProviderClient

Baseflow 1k Jan 5, 2023
Flutter Plugin for AR (Augmented Reality) - Supports ARKit on iOS and ARCore on Android devices

ar_flutter_plugin Flutter Plugin for AR (Augmented Reality) - Supports ARKit for iOS and ARCore for Android devices. Many thanks to Oleksandr Leuschen

Lars Carius 222 Jan 4, 2023
A lightweight Flutter plugin for making payments and printing on MyPos

my_poster ?? my_poster is in beta - please provide feedback (and/or contribute) if you find issues ??️ A lightweight Flutter plugin for making payment

Antonio Mentone 3 Oct 10, 2022
Telegram stickers importing Flutter plugin for iOS and Android

TelegramStickersImport — Telegram stickers importing Flutter plugin for iOS and Android TelegramStickersImport helps your users import third-party pro

Iurii Dorofeev 20 Dec 3, 2022
Plugin to access VPN service for Flutter | Flutter 的 VPN 插件

Flutter VPN plugin This plugin help developers to access VPN service in their flutter app. 本插件帮助开发者在自己的应用内调用 VPN 服务。 The Android part was implemented

Xdea 277 Dec 28, 2022
Support to update the app badge on the launcher (both for Android and iOS)

Flutter App Badger plugin This plugin for Flutter adds the ability to change the badge of the app in the launcher. It supports iOS and some Android de

Edouard Marquez 258 Dec 25, 2022
Flutter library for iOS Widgets Extensions. Integrate a Widget into your App 🍏📱

flutter_widgetkit Flutter Library for the iOS ?? WidgetKit framework and Widget Communication Table of Contents ?? Introduction ??‍?? Installation ??‍

Fasky 227 Dec 31, 2022
Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation with a minimum password strength required.

password_strength_checker Generate secure passwords, check for exposed passwords, get visual feedback for password strength or get form validation wit

Dario Varriale 6 Aug 8, 2023
Tesla car app using Flutter that works both android and iOS. Users can unlock any door, check battery status also control the air cooler temperature and check the psi of the tires.

Tesla App Tesla car app using Flutter that works both android and iOS. Users can unlock any door, check battery status also control the air cooler tem

null 12 Dec 18, 2022
Book app - Book app UI with dark mode enabled, also this app created using the Flutter 2.5 skeleton template

BOOK APP Book app UI with dark mode enabled, also this app created using the Flu

Gülsen Keskin 5 Nov 9, 2022
(mostly) Automatic search-enabled appBar for flutter

flutter_search_bar A simple and mostly automatic material search bar for flutter (dart). Note: use flutter_search_bar and not search_bar -- I own both

Spencer 266 Dec 31, 2022