Skip to main content

magic_device 1.1.0 copy "magic_device: ^1.1.0" to clipboard
magic_device: ^1.1.0 copied to clipboard

Gate background work in Flutter: detect mains power (charging), viewer idle and macOS window fullscreen. One import, no setup, no Runner edits.

Changelog #

All notable changes to this project will be documented in this file.

[Unreleased] #

1.1.0 - 2026-11-18 #

Added #

  • An Android plugin for the television check. MagicDevicePlugin on Android answers isTelevision on the magic_device/television channel from UiModeManager.currentModeType, and registers itself, so the host's MainActivity needs no edit. (#18)

Changed #

  • DevicePower.instance answers for an Android TV. On Android the default television reader asks the new plugin and reuses a settled answer (a missing plugin settles it on false; a PlatformException, or no Flutter binding yet, answers false for that read only), so a batteryless TV, which reports unknown, reads as on mains instead of gating work off for ever. With no plugin behind the channel it answers false. A testWidgets body that builds a DevicePower on Android without television: waits on a reply FakeAsync never delivers, so pass television: or a non-Android platform: there. iOS, macOS, Linux, Windows and the web answer false as before and never open the channel. (#18)
  • television may answer asynchronously. The constructor parameter is now FutureOr<bool> Function()?, so () => true still fits and a Future does too; an injected predicate still replaces the default. (#18)
  • The Changelog check now also counts a change under android/ as shipped code.

1.0.2 - 2026-11-16 #

Fixed #

  • pub.dev tags the package for every platform it runs on. The pubspec declared only macOS (the native WindowFullscreen plugin), so the package page showed a macOS-only package although DevicePower is plain Dart over battery_plus. A top-level platforms: key now declares Android, iOS, Linux, macOS and Windows. Web is left out on purpose: declaring it makes pana's WASM check fail and costs 10 points, while the code itself still runs on the web. (pubspec.yaml, README.md, llms.txt)

1.0.1 - 2026-11-15 #

Changed #

  • The package page is https://anilcancakir.com/magic/device and the documentation links sit under https://anilcancakir.com/magic/docs/device.

Fixed #

  • The docs and the agent skill now say "native macOS and Windows" where they said "macOS and Windows": a web build on a Mac attaches the lifecycle observer too, because the system-wide idle clock is read only on native macOS and Windows.
  • The agent skill's recipes (the power gate, the fullscreen button, the test) now compile as written, with their imports, and its WindowFullscreen rules and test notes no longer repeat the docs word for word.

1.0.0 - 2026-11-14 #

Changed #

  • First stable release: version 1.0.0 follows 0.0.2 with no API change beyond what is listed below.
  • The analyzer no longer suppresses unintended_html_in_doc_comment; the package analyzes clean without it.
  • Doc page leads are one sentence that says what the page is (the docs site copies it into its generated llms.txt), and the samples that use isTelevision say it is the host's own detection.

0.0.2 - 2026-11-13 #

Changed #

  • The repository moved to anilcancakir/magic_device. homepage (the package landing), repository and issue_tracker in pubspec.yaml point at the new owner, and the documentation key is gone (the landing links the docs, as for wind and magic), and the LICENSE holder is now Anılcan Çakır. The package name, the API and the version line are unchanged.

  • The default branch is master, protected: a pull request and green Lint & Test and Changelog checks are required, force pushes and deletion are blocked.

  • The publish workflow validates more and releases itself. It runs flutter pub publish --dry-run and requires a matching CHANGELOG section before publishing, then creates the GitHub Release from that section once pub.dev accepts the tag. Every action is pinned by commit SHA and the workflows run with read-only permissions by default.

  • The release workflow checks its own inputs. The tag must sit on master and name the same version as pubspec.yaml, the podspec and the agent skill, and the package must score the full 160 points on pana before anything is published.

  • Every change keeps the docs in step. The post-change checklist in CLAUDE.md and the pull request template now require the changelog, README, llms.txt, doc/ pages and the agent skill to match the change.

  • The pub.dev description and topics are written for search and for agents. The description leads with the job ("Gate background work in Flutter") and the three signals; the topics are battery, idle, power, fullscreen and magic, all existing pub.dev topics.

  • The package is no longer marked alpha. The README banner and the SECURITY note are gone; the version line continues as 0.0.x.

Added #

  • doc/: installation, DevicePower, WindowFullscreen and testing pages in the repository's docs standard, checked by tool/check-docs.py and the Docs Link Check workflow on every pull request.
  • SECURITY.md, issue forms for bugs and feature requests, and a pull request template.
  • A Changelog check: a pull request that changes lib/ or macos/ must also change CHANGELOG.md. Dependabot, release: pull requests and the skip-changelog label are exempt.
  • llms.txt: the package for an AI coding agent, with setup, the API, platform support and the rules an agent must follow.
  • skills/magic-device: an agent skill for the package, installed with npx skills add anilcancakir/magic_device. It stays out of the pub.dev archive.
  • The README opens with the Magic logo (.github/magic-logo.svg) and the centered header every Magic package uses.

0.0.1 - 2026-10-29 #

Added #

  • DevicePower: whether the device is on mains power (charging) and whether the viewer is away (idle). Desktop idle polls the OS last-input clock; mobile idle follows the app lifecycle, seeded from the current lifecycle state at start() so an app started in the background reads idle at once. television is an injectable predicate that defaults to () => false.
  • WindowFullscreen: whether the macOS window is fullscreen (active), where it is going (target, moved by AppKit's will-notification) and whether it is animating (transitioning), with toggle() to flip it. A press that the window never answers (AppKit ignores the call for an app that is not frontmost) ends after pressTimeout and re-reads the window, so it cannot hold every later toggle. One shared instance; listeners hear each change, whether it came from toggle(), the window's green button, Esc or the Window menu. available is true on macOS only. The native half is a macOS plugin (MagicDevicePlugin, channel magic_device/window) that finds the window holding the Flutter view on each call, so the host's Runner needs no edit.
  • BatteryState is exported from the barrel. DevicePower's batteryState reader returns it, so a host that supplies its own reader names the type without adding battery_plus as a direct dependency.
1
likes
160
points
3.39k
downloads

Documentation

API reference

Publisher

verified publisheranilcancakir.com

Weekly Downloads

Gate background work in Flutter: detect mains power (charging), viewer idle and macOS window fullscreen. One import, no setup, no Runner edits.

Homepage
Repository (GitHub)
View/report issues

Topics

#battery #idle #power #fullscreen #magic

License

MIT (license)

Dependencies

battery_plus, flutter, flutter_inactive_timer

More

Packages that depend on magic_device

Packages that implement magic_device