UsageStats class

Entry point for all usage-statistics queries. All methods are static.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

checkUsagePermission() Future<bool?>
Whether the PACKAGE_USAGE_STATS permission has been granted to this app.
getAppIcon(String packageName) Future<Uint8List?>
Returns the PNG-encoded launcher icon for packageName, or null if it cannot be resolved.
getAppInfo(String packageName) Future<AppInfo?>
Returns AppInfo metadata (label, system flag, version, install times) for packageName, or null if the package cannot be resolved.
getAppStandbyBucket() Future<int?>
This app's current App Standby bucket (e.g. 10 active, 20 working set, 30 frequent, 40 rare). Requires no permission.
grantUsagePermission() Future<void>
Opens the system "Usage access" settings screen so the user can grant the PACKAGE_USAGE_STATS permission. Does nothing if already granted.
isAppInactive(String packageName) Future<bool?>
Whether packageName is currently considered inactive (idle).
openUsageAccessSettings() Future<void>
Opens the system "Usage access" settings screen unconditionally, even when the permission is already granted (handy for a "Manage access" button).
queryAndAggregateUsageStats(DateTime startDate, DateTime endDate) Future<Map<String, UsageInfo>>
Returns per-app UsageInfo aggregated by package between startDate and endDate, keyed by package name.
queryConfiguration(DateTime startDate, DateTime endDate) Future<List<ConfigurationInfo>>
Returns the device ConfigurationInfo entries between startDate and endDate.
queryEvents(DateTime startDate, DateTime endDate) Future<List<EventUsageInfo>>
Returns the raw usage events between startDate and endDate.
queryEventsForSelf(DateTime startDate, DateTime endDate) Future<List<EventUsageInfo>>
Returns this app's own usage events between startDate and endDate without requiring PACKAGE_USAGE_STATS.
queryEventStats(DateTime startDate, DateTime endDate, {IntervalType? intervalType}) Future<List<EventInfo>>
Returns aggregated EventInfo statistics between startDate and endDate.
queryInstalledApps({bool includeSystem = true}) Future<List<AppInfo>>
Returns AppInfo for every installed app the caller is allowed to see.
queryNetworkUsageStats(DateTime startDate, DateTime endDate, {NetworkType networkType = NetworkType.all}) Future<List<NetworkInfo>>
Returns per-app NetworkInfo for all installed apps between startDate and endDate, for the given networkType.
queryNetworkUsageStatsByPackage(DateTime startDate, DateTime endDate, {required String packageName, NetworkType networkType = NetworkType.all}) Future<NetworkInfo>
Returns NetworkInfo for a single packageName between startDate and endDate, for the given networkType.
queryStorageStats(String packageName) Future<StorageInfo?>
Returns app/data/cache StorageInfo for packageName.
queryUsageStats(DateTime startDate, DateTime endDate, {IntervalType? intervalType}) Future<List<UsageInfo>>
Returns per-app UsageInfo statistics between startDate and endDate.