105 lines
3.3 KiB
Dart
105 lines
3.3 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';
|
|
import 'package:eagletracker/class/BLEProvider.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class DeviceAdvertizinScan extends StatefulWidget {
|
|
const DeviceAdvertizinScan(
|
|
{super.key,
|
|
required this.deviceName,
|
|
required this.deviceAddress,
|
|
required this.remoteId});
|
|
|
|
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),
|
|
);
|
|
|
|
String value = 'Aucune valeur reçue';
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final bleProvider = Provider.of<BLEProvider>(context);
|
|
scanResults = bleProvider.scanResults;
|
|
|
|
if (scanResults
|
|
.where((element) =>
|
|
element.advertisementData.manufacturerData.isNotEmpty &&
|
|
element.device.remoteId.toString() == widget.remoteId)
|
|
.isNotEmpty) {
|
|
value = scanResults
|
|
.where((element) =>
|
|
element.device.remoteId.toString() == widget.remoteId)
|
|
.map((e) => e.advertisementData.toString())
|
|
.first;
|
|
|
|
// Faites quelque chose avec la variable 'value' ici
|
|
}
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title:
|
|
const Text("Eagle Tr@cker", style: TextStyle(color: Colors.white)),
|
|
backgroundColor: Colors.blue,
|
|
leading: IconButton(
|
|
icon: const Icon(Icons.arrow_back, color: Colors.white),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
),
|
|
body: Column(
|
|
children: [
|
|
const Padding(
|
|
padding: EdgeInsets.all(16.0),
|
|
child: Text('Lecture de la trame publicitaire',
|
|
style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold)),
|
|
),
|
|
Container(
|
|
alignment: Alignment.topCenter,
|
|
child: Column(
|
|
children: [
|
|
Text(widget.deviceName),
|
|
Text(widget.deviceAddress),
|
|
Text(widget.remoteId),
|
|
],
|
|
)),
|
|
Container(
|
|
margin: const EdgeInsets.all(10),
|
|
child:
|
|
//Text centré
|
|
const Center(
|
|
child: Text(
|
|
"La trame publicitaire est en cours de réception et actualisée en temps réel.",
|
|
style: TextStyle(
|
|
color: Colors.green,
|
|
),
|
|
textAlign: TextAlign.center),
|
|
)),
|
|
Container(
|
|
margin: const EdgeInsets.all(10),
|
|
child: const CircularProgressIndicator()),
|
|
Container(
|
|
margin: const EdgeInsets.all(10),
|
|
alignment: Alignment.center,
|
|
child: Text(value,
|
|
style: const TextStyle(
|
|
color: Colors.black, fontWeight: FontWeight.bold))),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|