Skip to content

Commit

Permalink
Use ScanFilter ui for getting system devices
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitsangwan01 committed Jan 2, 2025
1 parent 1df269b commit d41b8cc
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions example/lib/home/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ class _MyAppState extends State<MyApp> {
);
}

Future<void> _getSystemDevices() async {
List<BleDevice> devices = await UniversalBle.getSystemDevices(
withServices: scanFilter?.withServices,
);
if (devices.isEmpty) {
showSnackbar("No Connected Devices Found");
}
setState(() {
_bleDevices.clear();
_bleDevices.addAll(devices);
});
}

void _showScanFilterBottomSheet() {
showModalBottomSheet(
isScrollControlled: true,
Expand Down Expand Up @@ -179,17 +192,7 @@ class _MyAppState extends State<MyApp> {
if (BleCapabilities.supportsConnectedDevicesApi)
PlatformButton(
text: 'Connected Devices',
onPressed: () async {
List<BleDevice> devices =
await UniversalBle.getSystemDevices();
if (devices.isEmpty) {
showSnackbar("No Connected Devices Found");
}
setState(() {
_bleDevices.clear();
_bleDevices.addAll(devices);
});
},
onPressed: _getSystemDevices,
),
PlatformButton(
text: 'Queue: ${_queueType.name}',
Expand Down

0 comments on commit d41b8cc

Please sign in to comment.