Skip to content

Commit

Permalink
Changed data display to hex array.
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldemarco committed Aug 11, 2018
1 parent 757c57f commit dc7f8e6
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions example/lib/widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,19 @@ class ScanResultTile extends StatelessWidget {
);
}

String getNiceHexArray(List<int> bytes) {
return '[${bytes.map((i) => i.toRadixString(16).padLeft(2, '0')).join(', ')}]'
.toUpperCase();
}

String getNiceManufacturerData(Map<int, List<int>> data) {
if (data.isEmpty) {
return null;
}
List<String> res = [];
data.forEach((id, bytes) {
res.add('${id.toRadixString(16).toUpperCase()}: $bytes');
res.add(
'${id.toRadixString(16).toUpperCase()}: ${getNiceHexArray(bytes)}');
});
return res.join(', ');
}
Expand All @@ -67,7 +73,7 @@ class ScanResultTile extends StatelessWidget {
}
List<String> res = [];
data.forEach((id, bytes) {
res.add('$id: $bytes');
res.add('$id: ${getNiceHexArray(bytes)}');
});
return res.join(', ');
}
Expand Down Expand Up @@ -98,7 +104,7 @@ class ScanResultTile extends StatelessWidget {
context,
'Service UUIDs',
(result.advertisementData.serviceUuids.isNotEmpty)
? result.advertisementData.serviceUuids.join(', ')
? result.advertisementData.serviceUuids.join(', ').toUpperCase()
: 'N/A'),
_buildAdvRow(context, 'Service Data',
getNiceServiceData(result.advertisementData.serviceData) ?? 'N/A'),
Expand Down

0 comments on commit dc7f8e6

Please sign in to comment.