usage_stats
2.0.1, released 6 months ago by an unverified publisher
Query Android app usage statistics, events, storage usage, and network data.
What it does
Wraps Android's UsageStatsManager, NetworkStatsManager, StorageStatsManager, and PackageManager behind a single Dart facade. It enables querying per-app foreground usage, raw events, network usage, storage statistics, and app metadata.
AI-written summary of version 2.0.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are building an Android-only app that needs to monitor app usage or screen time.
- You need to retrieve per-app network usage or on-device storage stats.
- You need to inspect installed apps and their launch icons.
Skip it when
- Your application needs to support iOS or platforms other than Android.
- You want to avoid requiring users to manually grant special permissions in system settings.
Strengths
- Provides a comprehensive suite of Android usage statistics APIs in one plugin.
- Includes typed getters on returned models to avoid manual parsing.
- Degrades gracefully on older Android API levels.
Weaknesses
- Android only; no iOS implementation exists.
- Most queries require the special PACKAGE_USAGE_STATS permission, which must be granted manually in system settings.
Setup
- Kind
- Plugin (native code)
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 0
Requires adding the PACKAGE_USAGE_STATS permission to AndroidManifest.xml and prompting users to enable it in system settings. Targets a minimum SDK of 23.
final endDate = DateTime.now();
final startDate = endDate.subtract(const Duration(days: 1));
List<UsageInfo> usage = await UsageStats.queryUsageStats(startDate, endDate);Alternatives
Packages that do the same job and could replace usage_stats.
- connection_network_type
Detects current network type and listens for connectivity changes on iOS and Android.
60Compare - data_saver
Check if Android Data Saver or iOS Low Data Mode is enabled.
67Compare