Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Request]: Stream for Battery Level Changes

Open
#3,733 1 comment 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Quiet
Tech stack
dart, flutter
Domain
mobile-dev

Research direction

Start by locating the battery_plus platform implementations and the existing onBatteryStateChanged stream entry point. Compare the iOS, Android, Web, and macOS battery-level APIs named in the issue, then verify that the new stream emits percentage changes natively on each supported platform without polling.

Written by the indexing model from the issue text.

Description

enhancement triage
Plugin

battery_plus

Use case

Currently, battery_plus only provides a Future for batteryLevel and a Stream for batteryState. To track level changes, developers are forced to use Timer.periodic to poll the getter, which is inefficient and not reactive.

Proposal

I would like to request a new stream: Stream onBatteryLevelChanged.

Platforms support this natively, so we should not need to rely on polling.

  • iOS: We can observe UIDevice.batteryLevelDidChangeNotification. Note: Apple documentation states this notification is sent no more frequently than once per minute, which is acceptable for most use cases.
  • Android: We can register a BroadcastReceiver for Intent.ACTION_BATTERY_CHANGED. This intent contains the EXTRA_LEVEL and EXTRA_SCALE to calculate the percentage immediately upon change.
  • Web: The BatteryManager has a built-in event listener: onlevelchange.
  • macOS: The system provides a system loop notification: kIOPSPowerSourceHaveToUpdateNotification

Something like:

// Current
Stream<BatteryState> get onBatteryStateChanged;

// Proposed
Stream<int> get onBatteryLevelChanged;
Additional Context
  • This issue streamlines the battery level, but a stream to listen to all battery aspects would the preferrable solution. See #3446
Dominant language
Dart
Stars
1.9k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fluttercommunity/plus_plugins

All issues in fluttercommunity/plus_plugins

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.