testing library
Types for writing a fake native platform in tests, passed to
BleShield(platform: ...). Not part of the runtime API: it follows the
vendored native layer and may change in any release.
Classes
- AndroidConnectionOptions
- AndroidDiscoverServicesOptions
- AndroidOptions
-
Scan models
Android options to scan devices
requestLocationPermission is used to request location permission on Android 12+ (API 31+).
scanMode is used to set the scan mode for Bluetooth LE scan.
Set reportDelayMillis timestamp for Bluetooth LE scan. If set to 0, you will be notified of scan results immediately.
If > 0, scan results are queued up and delivered after the requested delay or 5000 milliseconds (whichever is higher).
Note scan results may be delivered sooner if the internal buffers fill up.
callbackType, matchMode, and numOfMatches map directly to the equivalent
android.bluetooth.le.ScanSettingssetters. Whennull, the plugin leaves them at the platform default — set them only if you need to override platform-side advert de-duplication (e.g. on Pixel hardware where the default settings throttle advertisements compared with nRF Connect). - AppleAccessoryPickerItem
- One accessory the AccessorySetupKit picker can offer. Each item is shown as a separate entry in the system picker.
- AppleAccessorySetupOptions
- iOS 18+ options for discovering and authorizing Bluetooth accessories with AccessorySetupKit before connecting to them.
- AppleConnectionOptions
-
Apple options for
connect. - AppleDiscoverServicesOptions
- BleCapabilities
- BleCharacteristic
- BleCharacteristicValue
- A characteristic value update, delivered by notifications, indications or reads that report their value through the value callback.
- BleCharOperationMetadata
- Metadata attached with BleCharacteristic or BleDescriptor to use with BLE operations
- BleCommand
- BleConnectionChange
- A connection state change of a device, including the platform's error details when the change was not requested by the app.
- BleConnectionParametersChange
-
Link-layer connection parameters reported by Android
onConnectionUpdated. - BleDescriptor
- BleDevice
- BleService
- BleShieldNativePlatform
- BleUuidParser
- CharacteristicSubscription
- Manages subscription to a characteristic's notifications or indications.
- ConnectionPlatformConfig
- DiscoverServicesPlatformConfig
-
Platform-specific options for
discoverServices. Ignored on platforms that have no equivalent. - ExclusionFilter
- ManufacturerData
- Represents the manufacturer data of a BLE device.
- ManufacturerDataFilter
- PickerPlatformConfig
-
Platform specific config for
BleShieldNative.requestDevice, which presents the platform's native device picker. - PlatformConfig
- Platform specific config to scan devices.
- ScanFilter
- Filter criteria used to discover matching devices during BLE scanning.
- WebOptions
-
Web options to scan devices
optionalServices is a list of service uuid's to ensure that you can access the specified services after connecting to the device,
by default services from scanFilter will be used
optionalManufacturerData is list of
CompanyIdentifier'sand used to addManufacturerDatain advertisement results of selected device from web dialog, by default manufacturerData from scanFilter will be used Checkout more details on web Note: you will only get advertisements if Experimental Flag is enabled in the browser
Enums
- AndroidScanCallbackType
-
Mirrors
android.bluetooth.le.ScanSettings#setCallbackType. Pass any combination viaAndroidOptions.callbackType(the plugin OR-folds the list before callingsetCallbackType). - AndroidScanMatchMode
-
Mirrors
android.bluetooth.le.ScanSettings#setMatchMode. - AndroidScanMode
- AndroidScanNumOfMatches
-
Mirrors
android.bluetooth.le.ScanSettings#setNumOfMatches. - AvailabilityState
- BleConnectionPriority
-
Connection priority hint passed to
requestConnectionPriority. - BleConnectionState
- BleInputProperty
- BleLogLevel
- BleOutputProperty
- BleShieldNativeErrorCode
- Unified error codes for all platforms
- CharacteristicProperty
- QueueType
Extensions
- BleCharacteristicExtension on BleCharacteristic
- Extension methods for BleCharacteristic to simplify common operations.
- BleConnectionParametersChangeX on BleConnectionParametersChange
- Helpers for BleConnectionParametersChange reported on Android.
- BleDescriptorExtension on BleDescriptor
- Extension methods for BleDescriptor to simplify common operations.
- BleDeviceExtension on BleDevice
- Extension methods for BleDevice to simplify common operations.
- BleServiceExtension on BleService
- Extension methods for BleService objects.
-
FutureUint8ListExtension
on Future<
Uint8List> - Extensions on Future<Uint8List> to conveniently parse read results into numbers, strings, etc.
-
StringListToUUID
on List<
String> - Parse a list of strings to a list of UUIDs.
- Uint8ListExtension on Uint8List
- Extensions on Uint8List for common BLE byte payload operations.
Typedefs
- BleShieldPlatform = BleShieldNativePlatform
-
The native platform ble_shield runs on: the Pigeon channel in apps, a fake
in tests (see
package:ble_shield/testing.dart). - OnAvailabilityChange = void Function(AvailabilityState state)
- OnConnectionChange = void Function(BleConnectionChange change)
- Central mode callbacks
- OnConnectionParametersChange = void Function(BleConnectionParametersChange update)
- OnMtuChange = void Function(String deviceId, int mtu)
- OnPairingStateChange = void Function(String deviceId, bool isPaired)
- OnQueueUpdate = void Function(String deviceId, int mtu)
- OnScanResult = void Function(BleDevice scanResult)
- OnValueChange = void Function(BleCharacteristicValue value)
Exceptions / Errors
- BleShieldNativeException
- Base exception class for all BLE errors with typed error codes
- ConnectionException
- Exception thrown when connection-related errors occur
- PairingException
- Exception thrown when pairing-related errors occur
- WebBluetoothGloballyDisabled
- Exception thrown when Web Bluetooth API is globally disabled