device_apps_plus 1.0.2 copy "device_apps_plus: ^1.0.2" to clipboard
device_apps_plus: ^1.0.2 copied to clipboard

PlatformAndroid

A Flutter plugin to check if specific Android apps are installed on the device. Useful for deep links, onboarding, or app linking.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:device_apps_plus/device_apps_plus.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _outputText = 'Loading...';
  final _deviceAppsPlusPlugin = DeviceAppsPlus();

  final String singleApp = 'irando.co.id.holy_bible';
  final List<String> multipleApps = [
    'irando.co.id.holy_bible',
    'com.facebook.katana',
    'com.instagram.android',
    'com.google.android.youtube',
    'com.example.nonexistentapp',
  ];

  Map<String, bool> multiCheck = {};
  bool isHolyBibleInstalled = false;

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

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion =
          await _deviceAppsPlusPlugin.getPlatformVersion() ??
          'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    try {
      isHolyBibleInstalled = await _deviceAppsPlusPlugin.isAppInstalled(
        singleApp,
      );
      multiCheck = await _deviceAppsPlusPlugin.checkMultiple(multipleApps);
    } catch (e) {
      debugPrint("Error during app check: $e");
    }

    if (!mounted) return;

    setState(() {
      _outputText =
          '''
Platform: $platformVersion

✅ isAppInstalled('$singleApp') = $isHolyBibleInstalled

📦 checkMultiple:
${multiCheck.entries.map((e) => '${e.key}: ${e.value ? "✔️" : "❌"}').join('\n')}
''';
    });
  }

  Future<void> _tryOpenBibleApp() async {
    final success = await _deviceAppsPlusPlugin.openApp(singleApp);
    if (!success) {
      if (!mounted) return;
      ScaffoldMessenger.of(context).showSnackBar(
        const SnackBar(
          content: Text("Holy Bible app not installed or can't be opened."),
        ),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Device Apps Plus Demo')),
        body: SingleChildScrollView(
          padding: const EdgeInsets.all(16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(_outputText, style: const TextStyle(fontSize: 16)),
              const SizedBox(height: 24),
              ElevatedButton.icon(
                onPressed: _tryOpenBibleApp,
                icon: const Icon(Icons.open_in_new),
                label: const Text("Open Holy Bible App"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
150
points
125
downloads

Publisher

verified publishernicxonsolutions.com

Weekly Downloads

A Flutter plugin to check if specific Android apps are installed on the device. Useful for deep links, onboarding, or app linking.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on device_apps_plus

Packages that implement device_apps_plus