device_volume 2.0.0 copy "device_volume: ^2.0.0" to clipboard
device_volume: ^2.0.0 copied to clipboard

Control and observe the device volume from Flutter through native platform channels on Android, iOS, macOS, Windows, and Linux.

2.0.0 #

This is a complete platform-layer rewrite and contains intentional breaking API changes.

Breaking changes #

  • Replaced synchronous int operations with asynchronous Future<VolumeState> operations.
  • Changed streamVolume from Stream<int> to Stream<VolumeState>.
  • Exported VolumeState as part of the public API.
  • Added VolumeCapabilities and VolumeWriteSupport so applications can discover device-specific restrictions.
  • Removed getVolumeCompute, setVolumeCompute, incrementVolumeCompute, and decrementVolumeCompute.
  • Raised Android minimum SDK to 24, iOS to 13, and macOS to 10.15.

Platform architecture #

  • Replaced Dart FFI, FFIgen, JNIgen, and manual backend selection with Flutter platform plugins on Android, iOS, macOS, Windows, and Linux.
  • Added one MethodChannel for commands and one EventChannel for native volume changes on every platform.
  • Removed Dart-side 250 ms polling. Streams now use native observers or callbacks and deduplicate unchanged states.
  • Added per-engine lifecycle cleanup for observers, callbacks, channel handlers, COM objects, PulseAudio contexts, and temporary Apple views.
  • Added dual CocoaPods and Swift Package Manager support for iOS and macOS.

Android #

  • Replaced JNI calls and ActivityThread.currentApplication() with a Kotlin FlutterPlugin using the application context supplied by Flutter.
  • Added AudioManager support for media, ring, alarm, notification, voice-call, and system streams.
  • Added native stream observation through ContentObserver with state deduplication.
  • Added fixed-volume capability detection.
  • Added stable translation of DND/notification-policy SecurityException failures to PermissionDeniedException.
  • Preserved Android-native increment/decrement steps and optional system UI.

iOS #

  • Added Swift FlutterPlugin and FlutterStreamHandler implementations.
  • Added AVAudioSession.outputVolume reads and KVO events.
  • Kept real-device writes explicitly marked as bestEffort through MPVolumeView.
  • Removed main-thread sleeps; writes now verify state asynchronously.
  • Added explicit simulator write rejection and unsupported capabilities.

macOS #

  • Added an Objective-C Flutter plugin backed by CoreAudio.
  • Added listeners for output volume and default output device changes.
  • Added detection of output devices without readable or writable software volume.
  • Preserved virtual-main, scalar-master, and per-channel write fallbacks.

Windows #

  • Added a C++ Flutter plugin backed by IMMDeviceEnumerator and IAudioEndpointVolume.
  • Added IAudioEndpointVolumeCallback for volume/mute events.
  • Added IMMNotificationClient handling for default endpoint changes.
  • Marshalled COM callbacks to Flutter's window thread and added deterministic COM/interface cleanup.

Linux #

  • Added a Linux Flutter plugin using PulseAudio and libpulse-mainloop-glib.
  • Reused one asynchronous PulseAudio context per Flutter engine.
  • Added sink/server subscriptions for volume and default sink changes.
  • Removed the blocking per-operation PulseAudio main loop.
  • Added PipeWire-Pulse compatibility and explicit missing-backend errors.

Dart API and reliability #

  • Centralized native-range normalization in VolumeState.fromPlatform.
  • Added defensive range validation, clamping, and platform-payload validation.
  • Added stable error translation for unsupported operations, invalid values, permissions, unavailable backends, native failures, observation failures, and detached plugins.
  • Added a shared broadcast EventChannel transport filtered by logical channel.
  • Enabled strict casts, strict inference, and strict raw types in analysis.

Tests and example #

  • Added method-channel contract tests using Flutter's test binary messenger.
  • Added event-channel filtering tests with a mock native stream handler.
  • Added model, normalization, capability, facade, and exception tests.
  • Added hardware-aware integration tests that restore the original volume.
  • Rebuilt the example to display capabilities, restrictions, state, stream changes, channel selection, and best-effort notices.
  • Added stable widget keys for automated integration flows.

Documentation and tooling #

  • Rewrote the README with full API documentation, platform restrictions, architecture, error handling, migration examples, and validation commands.
  • Added official Dart and Flutter agent skills under .agents/skills with a provenance lock file.
  • Registered the official Dart/Flutter MCP server for analysis and test validation.
  • Added a release-blocking CI matrix with Android emulator, iOS simulator, macOS, Windows, and Linux/PulseAudio integration tests.
  • Made pub.dev publishing wait for the complete reusable CI workflow and a successful package dry run.

0.1.1 #

  • Changed public API methods to return normalized integers from 0 to 100.
  • Kept VolumeState internal.
  • Added public value validation and exception mapping tests.
  • Added Android native-range normalization.

0.1.0 #

  • Introduced the initial DeviceVolume facade.
  • Added synchronous and compute() variants for volume operations.
  • Added FFI backends for Apple, Windows, and Linux.
  • Added a JNIgen Android backend.
  • Added the initial models, exception hierarchy, example, and package metadata.
1
likes
160
points
133
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Control and observe the device volume from Flutter through native platform channels on Android, iOS, macOS, Windows, and Linux.

Repository (GitHub)
View/report issues

Topics

#volume #audio #method-channel #platform

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on device_volume

Packages that implement device_volume