parseBatteryLevel static method
Get the BatteryChargingState based on a battery level percentage (0-100).
Implementation
static BatteryChargingState parseBatteryLevel(int batteryLevel) =>
switch (batteryLevel) {
<= 10 => BatteryChargingState.critical,
> 10 && <= 20 => BatteryChargingState.low,
> 20 && <= 90 => BatteryChargingState.normal,
> 90 && <= 100 => BatteryChargingState.full,
_ => BatteryChargingState.unknown,
};