getBatteryIcon method

IconData getBatteryIcon(
  1. double percentage
)

An appropriate battery icon in increments of 1/8 battery level.

Implementation

IconData getBatteryIcon(double percentage) => switch (percentage) {
  >= 0.84 => Icons.battery_full,
  >= 0.72 => Icons.battery_6_bar,
  >= 0.60 => Icons.battery_5_bar,
  >= 0.48 => Icons.battery_4_bar,
  >= 0.36 => Icons.battery_3_bar,
  >= 0.24 => Icons.battery_2_bar,
  >= 0.12 => Icons.battery_1_bar,
  _       => Icons.battery_0_bar,
};