Skip to content
Merged
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.1.0

- **BREAKING**: Implementations must add `getApps` and `detectAppFrameworks`.
- **BREAKING**: Added `packageNameContains` to `listApps`; combine filters with AND.
- **BREAKING**: Removed `getInstallerStore`; use `getInstallSourceInfo`.
- Added the `AppFramework` enum.

## 1.0.0

- **BREAKING**: Raised the minimum Dart SDK version to 3.12.0.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# flutter\_device\_apps\_platform\_interface
# flutter_device_apps_platform_interface

<p align="center">
<a href="https://pub.dev/packages/flutter_device_apps_platform_interface"><img src="https://img.shields.io/pub/v/flutter_device_apps_platform_interface.svg?color=0175C2" alt="Pub"></a>
<a href="https://github.com/okmsbun/flutter_device_apps_platform_interface"><img src="https://img.shields.io/github/stars/okmsbun/flutter_device_apps_platform_interface.svg?style=flat&logo=github&colorB=deeppink&label=stars" alt="Star on Github"></a>
<a href="https://flutter.dev"><img src="https://img.shields.io/badge/flutter-website-deepskyblue.svg" alt="Flutter Website"></a>
<a href="https://pub.dev/packages/flutter_device_apps/score"><img src="https://img.shields.io/pub/points/flutter_device_apps" alt="flutter_device_apps Pub points"></a>
<a href="https://github.com/okmsbun/flutter_device_apps"><img src="https://img.shields.io/github/stars/okmsbun/flutter_device_apps.svg?style=flat&logo=github&colorB=deeppink&label=stars" alt="Star on Github"></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-purple.svg" alt="License: MIT"></a>
<a href="https://pub.dev/packages/flutter_device_apps"><img src="https://img.shields.io/badge/umbrella-package-orange.svg" alt="Umbrella Package"></a>
</p>
Expand Down
72 changes: 56 additions & 16 deletions lib/flutter_device_apps_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'flutter_device_apps_app_change_event.dart';

/// Framework or runtime families identified by known Android APK library names.
///
/// A match indicates a packaged component, not which technology renders every
/// screen or whether that component is currently in use.
enum AppFramework {
/// Flutter engine libraries.
flutter,

/// React Native libraries, including the legacy JNI library.
reactNative,

/// Unity engine libraries.
unity,

/// Unreal Engine libraries, including the legacy UE4 library.
unrealEngine,

/// Godot engine libraries.
godot,

/// .NET Android runtime glue; does not distinguish MAUI from Xamarin.
dotnetAndroid,
}

/// Information about an installed app on the device.
///
/// Contains metadata like package name, version, install times, and optional icon data.
Expand Down Expand Up @@ -221,18 +245,39 @@ abstract class FlutterDeviceAppsPlatform extends PlatformInterface {

/// Lists installed apps.
///
/// [packageNamePrefix] filters package names with a case-sensitive prefix
/// before loading app metadata and icons. Null or empty disables this filter.
/// [packageNamePrefix] matches the start of a package name, and
/// [packageNameContains] matches a substring anywhere in a package name.
/// Both filters are case-sensitive and run before loading app metadata and
/// icons. Null or empty disables each filter independently. When both are
/// provided, both must match.
Future<List<AppInfo>> listApps({
bool includeSystem = false,
bool onlyLaunchable = true,
bool includeIcons = false,
String? packageNamePrefix,
String? packageNameContains,
});

/// Gets details for a single app.
Future<AppInfo?> getApp(String packageName, {bool includeIcon = false});

/// Gets installed apps by their exact [packageNames] without listing all apps.
///
/// Returns each available package once, in order of its first occurrence.
/// Missing, hidden, and blank package names are skipped. An empty input returns
/// an empty list. Names are case-sensitive and are not trimmed.
/// Includes system apps and apps without a launcher entry when visible.
/// Set [includeIcons] to load icons alongside app metadata (default: false).
Future<List<AppInfo>> getApps(List<String> packageNames, {bool includeIcons = false});

/// Detects known framework library names in the base and installed split APKs.
///
/// Returns unique matches in [AppFramework.values] order. An empty list means
/// no supported indicator was found after all APKs were read successfully.
/// Throws if [packageName] is blank, missing or hidden, or any APK cannot be
/// read. Does not inspect DEX code or determine the app's primary UI framework.
Future<List<AppFramework>> detectAppFrameworks(String packageName);

/// Gets the app icon as PNG bytes without loading the full app metadata.
///
/// Returns null when the package is missing, not visible, or its icon resources
Expand Down Expand Up @@ -300,14 +345,6 @@ abstract class FlutterDeviceAppsPlatform extends PlatformInterface {
/// API 30, only installingPackageName is available. A returned model can have
/// null fields when Android does not provide the corresponding information.
Future<AppInstallSourceInfo?> getInstallSourceInfo(String packageName);

/// Gets the installer store for the specified package name.
///
/// Platform implementations should return the installer store for the given package.
/// Returns the installer store name or null if not available.
// Newly deprecated; retain the method for backwards compatibility.
@Deprecated('Use getInstallSourceInfo() and its installingPackageName instead.')
Future<String?> getInstallerStore(String packageName);
}

/// Default no-op implementation to throw if no platform is registered.
Expand All @@ -320,12 +357,21 @@ class _UnimplementedPlatform extends FlutterDeviceAppsPlatform {
bool onlyLaunchable = true,
bool includeIcons = false,
String? packageNamePrefix,
String? packageNameContains,
}) => Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));

@override
Future<AppInfo?> getApp(String packageName, {bool includeIcon = false}) =>
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));

@override
Future<List<AppInfo>> getApps(List<String> packageNames, {bool includeIcons = false}) =>
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));

@override
Future<List<AppFramework>> detectAppFrameworks(String packageName) =>
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));

@override
Future<Uint8List?> getAppIcon(String packageName) =>
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));
Expand Down Expand Up @@ -369,10 +415,4 @@ class _UnimplementedPlatform extends FlutterDeviceAppsPlatform {
@override
Future<AppInstallSourceInfo?> getInstallSourceInfo(String packageName) =>
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));

@override
// Newly deprecated; retain the method for backwards compatibility.
@Deprecated('Use getInstallSourceInfo() and its installingPackageName instead.')
Future<String?> getInstallerStore(String packageName) =>
Future.error(UnsupportedError('FlutterDeviceAppsPlatform not implemented'));
}
6 changes: 2 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
name: flutter_device_apps_platform_interface
description: Platform-agnostic API contract for flutter_device_apps (federated).
version: 1.0.0
version: 1.1.0
repository: https://github.com/okmsbun/flutter_device_apps_platform_interface
issue_tracker: https://github.com/okmsbun/flutter_device_apps/issues
topics:
- flutter
- android
- installed-apps
- app-management
- package-manager
Expand All @@ -18,4 +16,4 @@ dependencies:

dev_dependencies:
lints: 6.1.0
test: 1.32.0
test: 1.33.0
7 changes: 6 additions & 1 deletion test/package_queries_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import 'package:test/test.dart';
void main() {
test('an unregistered platform still reports unsupported operations', () async {
final FlutterDeviceAppsPlatform platform = FlutterDeviceAppsPlatform.instance;
await expectLater(platform.listApps(packageNamePrefix: 'com.example.'), throwsUnsupportedError);
await expectLater(
platform.listApps(packageNamePrefix: 'com.', packageNameContains: 'example'),
throwsUnsupportedError,
);
await expectLater(platform.getAppIcon('com.example.user'), throwsUnsupportedError);
await expectLater(platform.getApps(['com.example.user']), throwsUnsupportedError);
await expectLater(platform.detectAppFrameworks('com.example.user'), throwsUnsupportedError);
await expectLater(platform.isAppInstalled('com.example.user'), throwsUnsupportedError);
await expectLater(platform.isSystemApp('com.example.user'), throwsUnsupportedError);
await expectLater(platform.isAppEnabled('com.example.user'), throwsUnsupportedError);
Expand Down
Loading