Djihanegh / flutter_active_package

A Flutter plugin to help you get the package's name of any application running in foreground.

Home Page:https://pub.dev/packages/active_package

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

active_package

A Flutter plugin that helps you know the package name of any application running in foreground.

When it can be used

  • Know which app is opened in foreground while your app is running in background.
  • Get the package name of your main app.

Getting Started

Check the example folder for a complete working example about the plugin

Future<void> getPackageName() async {
  String packageName;
  try {
    packageName = await _activePackagePlugin.getActivePackageName() ??
        'Unknown package name';
  } catch (e) {
    packageName = 'Failed to get the active package name.';
  }

  // If the widget was removed from the tree while the asynchronous package name
  // method was in flight, we want to discard the reply rather than calling
  // setState to update our non-existent appearance.
  if (!mounted) return;

  setState(() {
    _packageName = packageName;
  });
}

About

A Flutter plugin to help you get the package's name of any application running in foreground.

https://pub.dev/packages/active_package

License:MIT License


Languages

Language:Dart 66.9%Language:Java 28.7%Language:Swift 4.0%Language:Objective-C 0.4%