bluetooth_manager 2.0.1
bluetooth_manager: ^2.0.1 copied to clipboard
A simple plugin to manage Bluetooth, turning on and off and getting Bluetooth state.
Changelog #
All notable changes to this project are documented in this file.
2.0.1 #
- Android: add
namespaceinandroid/build.gradle(required by AGP 8+), bumpcompileSdkto 35,minSdkto 21, and align Java compatibility to 17.
2.0.0 #
- New native architecture for iOS and macOS. Each platform now has its
own Swift plugin target (
ios/,macos/) sharing the same channel names (bluetooth_manager,bluetooth_manager/events) but compiled againstFlutter/FlutterMacOSrespectively. - Dart layer split by platform.
BluetoothManagerPathroutes calls to dedicated implementations:BluetoothManagerIOSandBluetoothManagerMacOSunderlib/path/ios/andlib/path/macos/. - macOS support (first-class). Read the Bluetooth adapter state, stream
state changes via
EventChannel(CBCentralManagerDelegate) and open the Bluetooth pane in System Settings throughenableBluetooth/disableBluetooth(returnsActionResponse.openedIOSSettings, same as iOS). - iOS plugin rebuilt on CoreBluetooth.
- Lazy-initialises
CBCentralManager, so the Bluetooth permission prompt appears only on the first state read or stream subscription — not at app launch. - Event-driven state stream via
CBCentralManagerDelegate(no polling). - Concurrent state reads through a pending-results queue with a 3-second
timeout that resolves to
uknowwhen the delegate never reports a state. CBManagerStatevalues other thanpoweredOn/poweredOffmap toBluetoothState.uknowinstead of throwing at runtime.openBluetoothSettingstries Bluetooth-specific URLs and falls back to the app’s Settings page when the system rejects deep links.
- Lazy-initialises
- Example app includes a
macos/runner with Bluetooth sandbox entitlement andNSBluetoothAlwaysUsageDescription. - Documentation updated across
README.mdand dartdoc comments.
1.0.12 #
- macOS support. Read the Bluetooth adapter state, stream state changes
via
EventChannel(CBCentralManagerDelegate) and open the Bluetooth pane in System Settings throughenableBluetooth/disableBluetooth(returnsActionResponse.openedIOSSettings, same as iOS). - Example app includes a
macos/runner with Bluetooth sandbox entitlement andNSBluetoothAlwaysUsageDescription.
1.0.11 #
- iOS now works. The Swift plugin was missing
import Flutterand never compiled; added it and wired the plugin correctly. - iOS state reading is safe.
CBManagerStatevalues that are notpoweredOn/poweredOffare now mapped toBluetoothState.uknowinstead of returning strings not present in the enum (which used to throw aTypeErrorat runtime). - iOS lazy-initialises
CBCentralManager, so the Bluetooth permission prompt is no longer shown at app launch — it now appears only when the first state read or stream subscription happens. - iOS supports concurrent state reads through a queue of pending
results and adds a 3-second timeout that resolves with
uknowif the delegate never reports a state. openBluetoothSettingson iOS (invoked byenableBluetooth/disableBluetooth) keeps returningActionResponse.openedIOSSettings.- Event-driven state stream on both platforms.
getBluetoothStateStreamis now backed by anEventChannel(bluetooth_manager/events) — aBroadcastReceiveron Android andCBCentralManagerDelegateon iOS. No more polling. Thetimerparameter is kept for backwards compatibility but ignored. - Android robustness.
- Fixed a broken Java reference-equality check on the plugin result
(
callResult == "version_error") that meant the error branch never fired. - Android 13+ (API 33):
enableBluetooth/disableBluetoothnow returnresponseErrorexplicitly, becauseBluetoothAdapter.enable()/disable()are no-ops for non-privileged apps on that SDK. - Missing
BLUETOOTH_CONNECTpermission is now caught and reported asresponseErrorinstead of crashing.
- Fixed a broken Java reference-equality check on the plugin result
(
enumFromStringis null-safe and generic (T? enumFromString<T>). All Dart platform implementations fall back toBluetoothState.uknow/ActionResponse.responseErrorwhen the native side returns an unexpected value, so the plugin never throws aTypeError.- Podspec metadata updated (version, summary, homepage, author).
- Documentation updated across
README.mdand dartdoc comments.
0.0.11 #
- Added documentation and usage examples.
0.0.1 #
- Initial release: read the Bluetooth state and enable/disable it on Android.