get_apps_flutter 0.0.3 copy "get_apps_flutter: ^0.0.3" to clipboard
get_apps_flutter: ^0.0.3 copied to clipboard

A plugin that allows you to get a list of messengers, emails or run any other application

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  var apps = <AppData>[];
  AppData? telegram;
  AppData? whatsApp;
  final getApps = const GetApps();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text("Get Apps app"),
          centerTitle: true,
        ),
        body: Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () async {
                  final appsList = await getApps.getInstalledMessengers();

                  setState(() {
                    apps = appsList;

                    telegram = appsList
                        .where(
                          (element) => element.type.isTelegram,
                        )
                        .firstOrNull;

                    whatsApp = appsList
                        .where(
                          (element) => element.type.isWhatsApp,
                        )
                        .firstOrNull;
                  });
                },
                child: const Text(
                  'Get list apps',
                ),
              ),
              if (whatsApp != null)
                ElevatedButton(
                  onPressed: () async {
                    await getApps.openMessengerApp(
                      type: MessengerType.whatsApp,
                      arg: '7999999999',
                    );
                  },
                  child: const Text(
                    'Open whatsApp',
                  ),
                ),
              if (telegram != null)
                ElevatedButton(
                  onPressed: () async {
                    await getApps.openMessengerApp(
                      type: MessengerType.telegram,
                      arg: 'test',
                    );
                  },
                  child: const Text(
                    'Open telegram',
                  ),
                ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
26
downloads

Publisher

unverified uploader

Weekly Downloads

A plugin that allows you to get a list of messengers, emails or run any other application

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on get_apps_flutter