diff --git a/README.md b/README.md index a5ea45f..456a37c 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,15 @@ List apps = await InstalledApps.getInstalledApps( Use `packageNamePrefix` to filter apps with package names starting with a specific prefix. +#### For Named Parameters, use `getInstalledAppsNamed()` +```dart +List apps = await InstalledApps.getInstalledAppsNamed( + withIcon: true, + packageNamePrefix: "com.example", +); +``` + + #### Get App Info with Package Name ``` dart diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index 1223ac8..c458193 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -1,9 +1,9 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/dhirajsharma/Drive/SDKs/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/dhirajsharma/Drive/Desk/Personal/Projects/Flutter/installed_apps/example" +export "FLUTTER_ROOT=C:\Users\sandh\dev\flutter" +export "FLUTTER_APPLICATION_PATH=D:\flutter_plugins\installed_apps\example" export "COCOAPODS_PARALLEL_CODE_SIGN=true" -export "FLUTTER_TARGET=lib/main.dart" +export "FLUTTER_TARGET=lib\main.dart" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" diff --git a/example/lib/screens/app_list.dart b/example/lib/screens/app_list.dart index 708d67e..5b469ed 100644 --- a/example/lib/screens/app_list.dart +++ b/example/lib/screens/app_list.dart @@ -18,7 +18,7 @@ class AppListScreen extends StatelessWidget { Widget _buildBody() { return FutureBuilder>( - future: InstalledApps.getInstalledApps(true, true), + future: InstalledApps.geInstalledAppsNamed(withIcon: true, excludeSystemApps: true), // using named method instead of positional builder: ( BuildContext buildContext, AsyncSnapshot> snapshot, diff --git a/example/pubspec.lock b/example/pubspec.lock index 33d8511..d9c124b 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -65,7 +65,7 @@ packages: path: ".." relative: true source: path - version: "1.5.0" + version: "1.5.2" leak_tracker: dependency: transitive description: diff --git a/lib/installed_apps.dart b/lib/installed_apps.dart index a3d12d2..8186fe3 100644 --- a/lib/installed_apps.dart +++ b/lib/installed_apps.dart @@ -28,6 +28,31 @@ class InstalledApps { return AppInfo.parseList(apps); } + /// Named method for [getInstalledApps] + /// Named parameters: [excludeSystemApps], [withIcon], [packageNamePrefix] + /// + /// Example 1: Default behavior + /// List apps = await geInstalledAppsNamed(); + /// + /// Example 2: Include system apps + /// apps = await geInstalledAppsNamed(excludeSystemApps: false); + /// + /// Example 3: Fetch with icons and specific package prefix + /// apps = await geInstalledAppsNamed( + /// withIcon: true, + /// packageNamePrefix: "com.example", + /// ); + /// + /// Returns a list of [AppInfo] objects representing the installed apps. + /// Internally User [getInstalledApps] method. + static Future> geInstalledAppsNamed({ + bool excludeSystemApps = true, + bool withIcon = false, + String packageNamePrefix = "", + }) async { + return getInstalledApps(excludeSystemApps, withIcon, packageNamePrefix); + } + /// Launches an app with the specified package name. /// /// [packageName] is the package name of the app to launch.