Skip to content

Add Named Parameter Method getInstalledAppsNamed for Improved Usability #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ List<AppInfo> apps = await InstalledApps.getInstalledApps(

Use `packageNamePrefix` to filter apps with package names starting with a specific prefix.

#### For Named Parameters, use `getInstalledAppsNamed()`
```dart
List<AppInfo> apps = await InstalledApps.getInstalledAppsNamed(
withIcon: true,
packageNamePrefix: "com.example",
);
```


#### Get App Info with Package Name

``` dart
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Flutter/flutter_export_environment.sh
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion example/lib/screens/app_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AppListScreen extends StatelessWidget {

Widget _buildBody() {
return FutureBuilder<List<AppInfo>>(
future: InstalledApps.getInstalledApps(true, true),
future: InstalledApps.geInstalledAppsNamed(withIcon: true, excludeSystemApps: true), // using named method instead of positional
builder: (
BuildContext buildContext,
AsyncSnapshot<List<AppInfo>> snapshot,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.5.0"
version: "1.5.2"
leak_tracker:
dependency: transitive
description:
Expand Down
25 changes: 25 additions & 0 deletions lib/installed_apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,31 @@ class InstalledApps {
return AppInfo.parseList(apps);
}

/// Named method for [getInstalledApps]
/// Named parameters: [excludeSystemApps], [withIcon], [packageNamePrefix]
///
/// Example 1: Default behavior
/// List<AppInfo> 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<List<AppInfo>> 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.
Expand Down