battery_plus_watchos 0.1.0
battery_plus_watchos: ^0.1.0 copied to clipboard
watchOS implementation of the battery_plus plugin, reporting battery level, charging state, and low-power mode from WKInterfaceDevice via dart:ffi.
battery_plus_watchos #
The watchOS implementation of battery_plus.
Scaffolded with flutter-watchos plugin port
and finished by hand as an FFI implementation over WKInterfaceDevice —
see PORTING_REPORT.md.
Usage #
dependencies:
battery_plus: ^6.0.0
battery_plus_watchos: ^0.1.0
final battery = Battery();
print(await battery.batteryLevel); // 0–100
print(await battery.batteryState); // charging / full / discharging
API coverage #
| Member | watchOS |
|---|---|
batteryLevel |
✅ WKInterfaceDevice.batteryLevel (monitoring auto-enabled) |
batteryState |
✅ WKInterfaceDevice.batteryState |
isInBatterySaveMode |
✅ NSProcessInfo.isLowPowerModeEnabled (watchOS 9+, else false) |
onBatteryStateChanged |
✅ poll-based — watchOS has no battery-change notification, so the stream polls every BatteryPlusWatchos.pollInterval (default 2s) and emits on change |
License #
The FlutterWatch Authors under a BSD-3-Clause license. See LICENSE for the full text.