android_boot_info 1.0.0
android_boot_info: ^1.0.0 copied to clipboard
A Flutter plugin for Android that provides boot time, uptime, awake time, and deep sleep statistics.
android_boot_info #
A Flutter plugin for Android that provides boot time, uptime, awake time, and deep sleep statistics.
Features #
- π
Boot time (
DateTime, ISO string, milliseconds) - π Boot count
- β±οΈ Uptime (
Duration, milliseconds, seconds) - π Awake time (
Duration, milliseconds, seconds, percent) - π Deep sleep time (
Duration, milliseconds, seconds, percent)
Getting Started #
Add the dependency in your pubspec.yaml:
dependencies:
android_boot_info: ^1.0.0
Import the package:
import 'package:android_boot_info/android_boot_info.dart';
Usage #
import 'package:android_boot_info/android_boot_info.dart';
/// Boot time as a [DateTime].
final DateTime bootTime = await AndroidBootInfo.getBootTime();
/// Boot time formatted as ISOβ8601 string.
final String bootTimeISO = await AndroidBootInfo.getBootTimeISO();
/// Boot time in milliseconds since epoch.
final int bootTimeMs = await AndroidBootInfo.getBootTimeMs();
/// Number of times the device has booted.
final int bootCount = await AndroidBootInfo.getBootCount();
/// Total uptime since boot as [Duration].
final Duration uptimeDuration = await AndroidBootInfo.getUptimeDuration();
/// Uptime in milliseconds.
final int uptimeMs = await AndroidBootInfo.getUptimeMs();
/// Uptime in seconds.
final int uptimeSeconds = await AndroidBootInfo.getUptimeSeconds();
/// Total awake time since boot as [Duration].
final Duration awakeDuration = await AndroidBootInfo.getAwakeDuration();
/// Awake time in milliseconds.
final int awakeMs = await AndroidBootInfo.getAwakeMs();
/// Awake time in seconds.
final int awakeSeconds = await AndroidBootInfo.getAwakeSeconds();
/// Percentage of uptime spent awake.
final double awakePercent = await AndroidBootInfo.getAwakePercent();
/// Total deep sleep time since boot as [Duration].
final Duration deepSleepDuration = await AndroidBootInfo.getDeepSleepDuration();
/// Deep sleep time in milliseconds.
final int deepSleepMs = await AndroidBootInfo.getDeepSleepMs();
/// Deep sleep time in seconds.
final int deepSleepSeconds = await AndroidBootInfo.getDeepSleepSeconds();
/// Percentage of uptime spent in deep sleep.
final double deepSleepPercent = await AndroidBootInfo.getDeepSleepPercent();
/// π Refreshing Data
await AndroidBootInfo.refresh();
Note: By default, the plugin caches the last fetched snapshot.
CallAndroidBootInfo.refresh()to force a fresh read from the native side.
Platform Support #
| Platform | Support |
|---|---|
| Android | β |
License #
BSD 3-Clause License. See LICENSE for details.