Search packages, repositories and app categories

Package detailsv1.1.2

disable_battery_optimization

Flutter plugin to check and disable battery optimizations. Also shows custom steps to disable the optimizations in devices like mi, xiaomi, samsung, oppo, huawei, oneplus etc

Android
30-day downloads
13.9K
Likes
129
Pub points
150

Install package

flutter pub add disable_battery_optimization

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A Flutter plugin that checks and disables battery optimizations on Android devices, particularly useful for apps requiring background execution. It provides tailored instructions for popular brands like Xiaomi, Samsung, Oppo, Huawei, and OnePlus, guiding users through manual steps to ensure uninterrupted app performance. The plugin enhances reliability for services such as location tracking, push notifications, and background sync by preventing the OS from restricting app activity.

Use cases

  • Background task execution
  • Location tracking in the background
  • Push notification reliability
  • Long-running data sync
  • App performance optimization
  • Battery life management

Key features

  • Device-specific optimization guides
  • Automatic battery optimization check
  • Support for major Android brands
  • Simple integration with Flutter
  • Clear user instructions
  • Cross-device compatibility

Suitable for

  • Apps needing persistent background processes
  • Developers targeting Android OEMs
  • Services requiring reliable foreground execution
  • Mobile apps with real-time updates
  • Enterprise or utility applications

Considerations

  • Requires Android platform only
  • User interaction needed for some steps
  • Limited to Android device manufacturers listed
  • May require permission requests
  • Not applicable to iOS devices

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

disable_battery_optimization

Flutter plugin to check and disable battery optimizations. Also shows custom steps to disable the manufacturer specific optimizations on devices like mi, xiaomi, samsung, oppo, huawei, oneplus etc


Auto start
bool isAutoStartEnabled = await DisableBatteryOptimization.isAutoStartEnabled;

This will return true, for the devices which doesn't support auto start configuration as well for the devices on which, user has clicked on positive action for the auto start configuration dialog.

await DisableBatteryOptimization.showEnableAutoStartSettings("Enable Auto Start", "Follow the steps and enable the auto start of this app");

This will show a dialog with steps to enable auto start permission on the current device (if it's available)

Note: We cannot determine if the user has actually enabled the auto start permission or not. We can only show a dialog with the steps to enable.


Android Battery Optimization
bool isBatteryOptimizationDisabled = await DisableBatteryOptimization.isBatteryOptimizationDisabled;

This will return true, only if the user has disabled the 'native' battery optimization for this app.

await DisableBatteryOptimization.showDisableBatteryOptimizationSettings();

This will ask for the permission to disable battery optimization for the app.


Manufacturer specific Battery Optimization
bool isManBatteryOptimizationDisabled = await DisableBatteryOptimization.isManufacturerBatteryOptimizationDisabled;

This will return true, for the devices which doesn't support manufacturer specific battery optimization configuration as well for the devices on which, user has clicked on positive action for the manufacturer specific battery optimization configuration dialog.

await DisableBatteryOptimization.showDisableManufacturerBatteryOptimizationSettings("Your device has additional battery optimization", "Follow the steps and disable the optimizations to allow smooth functioning of this app");

This will show a dialog with steps to disable the manufacturer specific battery optimization on the current device (if it's available)

Note: We cannot determine if the user has actually disabled the manufacturer specific battery optimization or not. We can only show a dialog with the steps to disable it.


There are other helper methods available to check if all the permissions are enabled or disabled.

await DisableBatteryOptimization.isAllBatteryOptimizationDisabled
await DisableBatteryOptimization.showDisableAllOptimizationsSettings

Categories

Source repository

Projects using this package