Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pichillilorenzo/flutter_appavailability
A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.
https://github.com/pichillilorenzo/flutter_appavailability
android dart flutter flutter-package flutter-plugin ios plugin swift
Last synced: 26 days ago
JSON representation
A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.
- Host: GitHub
- URL: https://github.com/pichillilorenzo/flutter_appavailability
- Owner: pichillilorenzo
- License: mit
- Created: 2018-09-12T11:05:40.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-31T11:01:32.000Z (almost 2 years ago)
- Last Synced: 2024-09-29T09:41:04.443Z (about 1 month ago)
- Topics: android, dart, flutter, flutter-package, flutter-plugin, ios, plugin, swift
- Language: Dart
- Homepage: https://pub.dartlang.org/packages/flutter_appavailability
- Size: 140 KB
- Stars: 92
- Watchers: 5
- Forks: 90
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Flutter AppAvailability Plugin
[![Pub](https://img.shields.io/pub/v/flutter_appavailability.svg)](https://pub.dartlang.org/packages/flutter_appavailability)
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](https://github.com/ohh2ahh/AppAvailability).
## Getting Started
For help getting started with Flutter, view our online
[documentation](https://flutter.io/).For help on editing plugin code, view the [documentation](https://flutter.io/developing-packages/#edit-plugin-package).
## Installation
First, add `flutter_appavailability` as a [dependency in your pubspec.yaml file](https://flutter.io/using-packages/).## Methods available
- `checkAvailability(String uri)`
- `getInstalledApps()` (only for **Android**)
- `isAppEnabled(String uri)` (only for **Android**)
- `launchApp(String uri)`See the [docs](https://pub.dartlang.org/documentation/flutter_appavailability/latest/).
## Example
Here is a small example flutter app displaying a list of installed apps that you can launch.
```dart
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 {
List> installedApps;
List> 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 getApps() async {
List> _installedApps;if (Platform.isAndroid) {
_installedApps = await AppAvailability.getInstalledApps();
print(await AppAvailability.checkAvailability("com.android.chrome"));
// Returns: Map{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{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](https://user-images.githubusercontent.com/5956938/45448682-48c49e80-b6d3-11e8-8e56-5972b017e233.png)iOS:
![simulator screen shot - iphone x - 2018-09-12 at 21 27 05](https://user-images.githubusercontent.com/5956938/45448686-4a8e6200-b6d3-11e8-841c-be5b609b8c9b.png)