Scan BLE device

Sets scan listener

When the scan is enabled, the scan event listener stream bleScanEveStm will be triggered, and the scan result will be returned through the bleScanEveStm listener stream and stored in the “event” as a BleScanEvent object.

  (BleScanBean event) async {
    /// Do something with new state 

Callback Description:


callback valuecallback value typecallback value description
isCompletedboolis completed
addressStringDevice address
mRssiintequipment rssi
mScanRecordList< int >Bluetooth scan device record
nameStringEquipment name

Start scan

When scanning Bluetooth devices, it will first obtain the open status of Bluetooth, and only when the permission is allowed and the Bluetooth is turned on can start normal scanning.

_blePlugin.startScan(10*1000).then((value) => {
     /// Do something with new state 
    }).onError((error, stackTrace) => {

Parameter Description :

  • The scan duration can be set in milliseconds.
  • Since Bluetooth scanning is a time-consuming operation, it is recommended to set the scanning time to 10 seconds.

Cancel scan

Turn off the bluetooth scan, and the result listens to the callback through the bleScanEveStm data stream.

Last Updated: