ScanFilter class

The ScanFilter class is used to define criteria that determine which Bluetooth devices are returned during a scan for BLE (Bluetooth Low Energy) devices.

Scanning for BLE devices can be a resource-intensive process, especially when many devices are within range. By using filters, the scanning process can be tailored to detect only devices that match certain criteria, thereby making the process more efficient and focused.

The ScanFilter class allows for filtering based on various properties of the Bluetooth devices, such as:

  • Device Name: The human-readable name of the device.
  • Device Address: The unique hardware address of the device.
  • Manufacturer Data: Custom data provided by the manufacturer of the device.
  • Service UUIDs: Specific universally unique identifiers (UUIDs) for services provided by the device.
  • Service Data: Data related to a specific service provided by the device.

By using one or more of these properties, the ScanFilter class enables applications to find and interact with only those devices that are of interest. For instance, an application might use a ScanFilter to look only for devices that provide a particular service or that have a specific name.

Example usage:

var filter = ScanFilter(deviceName: 'DeviceName');

Constructors

ScanFilter({String? deviceName, List<String>? serviceUuids, int? manufacturerId, Map<int, List<int>>? manufacturerData})
Constructs a ScanFilter instance with specified filter parameters.

Properties

deviceName String?
The device name that should match the device's advertised name.
final
hashCode int
The hash code for this object.
no setterinherited
manufacturerData Map<int, List<int>>?
Additional manufacturer data that must match the advertised data.
final
manufacturerId int?
The manufacturer ID associated with a specific device manufacturer.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serviceUuids List<String>?
The service UUIDs that should match the advertised service UUIDs.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toMap() Map<String, dynamic>
Converts the ScanFilter instance into a map representation.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited