Last updated:
0 purchases
optimization battery
optimization_battery #
check if the app is ignoring battery optimizations , open IGNORE BATTERY OPTIMIZATION SETTINGS (Android Only)
Check if app is ignoring battery optimization #
OptimizationBattery.isIgnoringBatteryOptimizations().then((onValue) {
setState(() {
if (onValue) {
// Igonring Battery Optimization
} else {
// App is under battery optimization
}
});
});
copied to clipboard
Take user to battery optimization settings #
this opens the battery optimization settings. Apps can be placed on the whitelist through the settings UI
OptimizationBattery.openBatteryOptimizationSettings();
copied to clipboard
BatteryOptimizations Observer #
use BatteryOptimizationsObserver widget to detect the IgnoringBatteryOptimizations value after user openBatteryOptimizationSettings and return to the app
BatteryOptimizationsObserver(builder: (context, isIgonre) {
return Column(
children: [
Text('isIgonred : $isIgonre'),
if (isIgonre != null && !isIgonre)
ElevatedButton(
onPressed: () {
OptimizationBattery.openBatteryOptimizationSettings();
},
child: const Text("open igonre battery setting"))
],
);
})
copied to clipboard
isIgonre will be null on ios and also at start before complete loading the state and will update the value every time user return to the app
CREDIT : #
this plugin is inspired from battery_optimization but with supporting null safety and new android plugin APIs and BatteryOptimizationsObserver
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.