[Bug]: Battery save mode not available.
Platform
10
Plugin
battery_plus
Version
^2.1.4
Flutter SDK
2.8.1
Steps to reproduce
Run the application.
This crash occurs only on my Xiaomi Mi 9T Pro


Code Sample
Battery().isInBatterySaveMode.then((isInSaveMode) {
if (Platform.isIOS || !isInSaveMode || Prefs.isBatterySaverDetected) {
return;
} else {
Future.delayed(Duration.zero, () => showBatterySaverDetectionDialog());
}
}).catchError((e) {
print(e);
});
Logs
No data.
Flutter Doctor
Flutter 2.8.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 77d935af4d (8 months ago) • 2021-12-16 08:37:33 -0800
Engine • revision 890a5fca2e
Tools • Dart 2.15.1
Well, if save mode is not available on the device, there's not much we can do :)
inInBatterySaveMode returns a bool, so we cannot return a different state (like unavailable).
Probably improving documentation and explaining that the method will throw is good enough.
Still, is good practice to catch all errors that can come from native platform calls just in case.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days
Can you please reopen the issue? This happens on a Huawei P30 Lite which has a battery save mode, so this shouldn't throw an exception.