Skip to content

Commit 1d5a0c2

Browse files
authored
Merge pull request #2 from okmsbun/develop
Add category field to AppInfo class for Android app categorization
2 parents f712987 + 195aed3 commit 1d5a0c2

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/flutter_device_apps_platform_interface.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class AppInfo {
2020
this.lastUpdateTime,
2121
this.isSystem,
2222
this.iconBytes,
23+
this.category,
2324
});
2425

2526
/// Creates an [AppInfo] from a map of key-value pairs.
@@ -37,6 +38,7 @@ class AppInfo {
3738
final DateTime? lastUpdateTimeDate =
3839
lastUpdateTime != null ? DateTime.fromMillisecondsSinceEpoch(lastUpdateTime) : null;
3940

41+
final int? category = m['category'] != null ? int.tryParse(m['category']!.toString()) : null;
4042
return AppInfo(
4143
packageName: m['packageName']?.toString(),
4244
appName: m['appName']?.toString(),
@@ -47,6 +49,7 @@ class AppInfo {
4749
isSystem: m['isSystem'] != null ? bool.tryParse(m['isSystem']!.toString()) : null,
4850
iconBytes:
4951
m['iconBytes'] is List<int> ? Uint8List.fromList(m['iconBytes']! as List<int>) : null,
52+
category: category,
5053
);
5154
}
5255

@@ -74,6 +77,9 @@ class AppInfo {
7477
/// The app icon as raw bytes, if requested and available.
7578
final Uint8List? iconBytes;
7679

80+
/// App category (Android [ApplicationInfo.category], API 26+). Raw int from platform. Null when not set or API < 26.
81+
final int? category;
82+
7783
/// Converts this [AppInfo] to a map representation.
7884
///
7985
/// Useful for serialization to platform channels or other data formats.
@@ -86,6 +92,7 @@ class AppInfo {
8692
'lastUpdateTime': lastUpdateTime?.millisecondsSinceEpoch,
8793
'isSystem': isSystem,
8894
'iconBytes': iconBytes,
95+
'category': category,
8996
};
9097
}
9198

0 commit comments

Comments
 (0)