92 lines
2.7 KiB
Dart
92 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
|
import 'package:flutter_osm_plugin/flutter_osm_plugin.dart';
|
|
|
|
class DeviceAdvertizinScan extends StatefulWidget {
|
|
const DeviceAdvertizinScan(
|
|
{super.key,
|
|
required this.title,
|
|
required this.deviceName,
|
|
required this.deviceAddress,
|
|
required this.remoteId});
|
|
|
|
final String title;
|
|
final String deviceName;
|
|
final String deviceAddress;
|
|
final String remoteId;
|
|
|
|
@override
|
|
State<DeviceAdvertizinScan> createState() => _DeviceAdvertizinScanState();
|
|
}
|
|
|
|
class _DeviceAdvertizinScanState extends State<DeviceAdvertizinScan> {
|
|
List<ScanResult> scanResults = [];
|
|
|
|
TextEditingController tecTakingPoint = TextEditingController();
|
|
MapController mapController = MapController(
|
|
initPosition: GeoPoint(latitude: 47.4358055, longitude: 8.4737324),
|
|
);
|
|
|
|
@override
|
|
void initState() {
|
|
tecTakingPoint.text = '5';
|
|
FlutterBluePlus.startScan();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
FlutterBluePlus.stopScan();
|
|
print('Page disposed');
|
|
super.dispose();
|
|
}
|
|
|
|
String value = 'Aucune valeur trouvée';
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
FlutterBluePlus.onScanResults.listen((results) {
|
|
setState(() {
|
|
if (results.length > 0) value = results[0].toString();
|
|
});
|
|
});
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(widget.title, style: const TextStyle(color: Colors.white)),
|
|
backgroundColor: Colors.blue,
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
|
onPressed: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Text(
|
|
'(debug) Vous devez redémarrer l application et réaliser un nouveau scan pour voir les nouvelles valeurs (FlutterBluePlus.startScan())'),
|
|
),
|
|
);
|
|
return;
|
|
},
|
|
),
|
|
),
|
|
body: Column(
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.topCenter,
|
|
child: Text('Advertizin data value for ${widget.deviceName}' +
|
|
' with remoteId ${widget.remoteId}')),
|
|
Container(
|
|
alignment: Alignment.center,
|
|
child: Text(value,
|
|
style: const TextStyle(
|
|
color: Colors.black,
|
|
fontSize: 20,
|
|
fontWeight: FontWeight.bold))),
|
|
Container(child: CircularProgressIndicator()),
|
|
Spacer(),
|
|
Container(
|
|
child: Text(
|
|
'La trame publicitaire est en cours de réception et actualisée en temps réel.')),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|