device_volume 2.0.0
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
intoperations with asynchronousFuture<VolumeState>operations. - Changed
streamVolumefromStream<int>toStream<VolumeState>. - Exported
VolumeStateas part of the public API. - Added
VolumeCapabilitiesandVolumeWriteSupportso applications can discover device-specific restrictions. - Removed
getVolumeCompute,setVolumeCompute,incrementVolumeCompute, anddecrementVolumeCompute. - 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
MethodChannelfor commands and oneEventChannelfor 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 KotlinFlutterPluginusing the application context supplied by Flutter. - Added
AudioManagersupport for media, ring, alarm, notification, voice-call, and system streams. - Added native stream observation through
ContentObserverwith state deduplication. - Added fixed-volume capability detection.
- Added stable translation of DND/notification-policy
SecurityExceptionfailures toPermissionDeniedException. - Preserved Android-native increment/decrement steps and optional system UI.
iOS #
- Added Swift
FlutterPluginandFlutterStreamHandlerimplementations. - Added
AVAudioSession.outputVolumereads and KVO events. - Kept real-device writes explicitly marked as
bestEffortthroughMPVolumeView. - 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
IMMDeviceEnumeratorandIAudioEndpointVolume. - Added
IAudioEndpointVolumeCallbackfor volume/mute events. - Added
IMMNotificationClienthandling 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/skillswith 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
VolumeStateinternal. - Added public value validation and exception mapping tests.
- Added Android native-range normalization.
0.1.0 #
- Introduced the initial
DeviceVolumefacade. - 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.