Skip to content
pubscout

battery_optimization_helper

0.2.0, released 9 months ago by techlinkmyanmar.com

Detect and request disabling Android battery optimization with OEM auto-start shortcuts.

WASM-ready
$ flutter pub add battery_optimization_helper
Source repository

What it does

A Flutter plugin for Android that checks if battery optimization is enabled, prompts the user to disable it, and opens system settings. It also includes best-effort shortcuts for OEM-specific auto-start and background execution settings.

AI-written summary of version 0.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • Your app requires reliable background execution on Android devices.
  • You need to check battery restriction status or prompt users to ignore battery optimizations.

Skip it when

  • You are targeting iOS or non-Android platforms where battery optimization controls do not apply.
  • Your app does not perform background work.

Strengths

  • Provides typed optimization outcomes for clearer user flows.
  • Includes a diagnostics snapshot API for inspecting device manufacturer and power save state.
  • Covers multiple OEM background and auto-start settings paths.

Weaknesses

  • OEM auto-start settings paths differ by device and may fail or return false depending on the hardware.
  • Android-only functionality.

Setup

Kind
Plugin (native code)
Effort
Low
Code generation
No
Direct dependencies
1

Declares REQUEST_IGNORE_BATTERY_OPTIMIZATIONS permission by default, which can be modified via manifest merge rules if needed.

import 'package:battery_optimization_helper/battery_optimization_helper.dart';

Future<void> example() async {
  final outcome = await BatteryOptimizationHelper.ensureOptimizationDisabledDetailed(
    openSettingsIfDirectRequestNotPossible: true,
  );
  final snapshot = await BatteryOptimizationHelper.getBatteryRestrictionSnapshot();
}

Alternatives

Packages that do the same job and could replace battery_optimization_helper.

Works with

Packages commonly used together with battery_optimization_helper: ones it builds on, ones built on it, and its own family.