7dc22c58a5
* Improve scan filter api * Implement Windows filters * Add manufacturerDataList and deprecate manufacturerData * Fix Windows * Update Readme and changelog * Remove import * Fix Linux * Update readme and changelog * Cleanup Todo * Improve ManufacturerData * Rename webConfig and Manufacturer.data * Return false for receivesAdvertisements on Linux/Web * Add delay in discoverServices on Linux * Remove import * Update changelog --------- Co-authored-by: fotidim <foti@navideck.com>
51 lines
1.6 KiB
Dart
51 lines
1.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:universal_ble/universal_ble.dart';
|
|
|
|
class ScannedItemWidget extends StatelessWidget {
|
|
final BleDevice bleDevice;
|
|
final VoidCallback? onTap;
|
|
const ScannedItemWidget({super.key, required this.bleDevice, this.onTap});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
String? name = bleDevice.name;
|
|
List<ManufacturerData> rawManufacturerData = bleDevice.manufacturerDataList;
|
|
ManufacturerData? manufacturerData;
|
|
if (rawManufacturerData.isNotEmpty) {
|
|
manufacturerData = rawManufacturerData.first;
|
|
}
|
|
if (name == null || name.isEmpty) name = 'NA';
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
|
child: Card(
|
|
child: ListTile(
|
|
title: Text(
|
|
'$name (${bleDevice.rssi})',
|
|
),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(bleDevice.deviceId),
|
|
Visibility(
|
|
visible: manufacturerData != null,
|
|
child: Text(manufacturerData.toString()),
|
|
),
|
|
bleDevice.isPaired == true
|
|
? const Text(
|
|
"Paired",
|
|
style: TextStyle(color: Colors.green),
|
|
)
|
|
: const Text(
|
|
"Not Paired",
|
|
style: TextStyle(color: Colors.red),
|
|
),
|
|
],
|
|
),
|
|
trailing: const Icon(Icons.arrow_forward_ios),
|
|
onTap: onTap,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|