flutter_ble_lib library
Library for handling Bluetooth Low Energy functionality.
The library is organised around a few base entities, which are:
You have to create an instance of BleManager and initialise underlying native resources. Using that instance you then obtain an instance of Peripheral, which can be used to run operations on the corresponding peripheral.
All operations passing the Dart-native bridge are asynchronous, hence all operations in the plugin return either Future or Stream.
The library handles scanning for peripherals, connecting to peripherals, service discovery process on peripherals, manipulating characteristics and descriptors.
Bonding is handled transparently by the platform's operating system.
You can also listen to changes of Bluetooth adapter's state.
BleManager bleManager = BleManager();
await bleManager.createClient(); //ready to go!
//your BLE logic
bleManager.destroyClient(); //remember to release native resources when you're done!
For more samples refer to specific classes.
Classes
- AdvertisementData
- Data advertised by the Peripheral: power level, local name, manufacturer's data, advertised Services
- BleError
- BleErrorCode
- BleManager
- Entry point for library operations, handling allocation and deallocation of underlying native resources and obtaining Peripheral instances.
- CallbackType
- Type of scan for peripherals callback - Android only.
- Characteristic
- Representation of a single GATT Characteristic nested inside a Service.
- CharacteristicWithValue
- Characteristic extended with value property.
- Descriptor
- DescriptorWithValue
- Peripheral
- Representation of a unique peripheral
- ScanMode
- Mode of scan for peripherals - Android only.
- ScanResult
- A scan result emitted by the scanning operation, containing Peripheral and AdvertisementData.
- Service
- A collection of Characteristics and associated behaviors.
Enums
- BluetoothState
- State of the Bluetooth Adapter.
- LogLevel
- Level of details library is to output in logs.
- PeripheralConnectionState
- Enum covers all possible connection state
Typedefs
-
RestoreStateAction
= dynamic Function(List<
Peripheral> peripherals) - Callback used to inform about peripherals restored by the system.