1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import 'package:flutter/material.dart';
class ESenseConnectDialog extends StatefulWidget {
final void Function(String) connect;
final ValueNotifier<String> deviceStatus;
const ESenseConnectDialog(
{super.key, required this.deviceStatus, required this.connect});
@override
State<ESenseConnectDialog> createState() => _ESenseConnectDialogState();
}
class _ESenseConnectDialogState extends State<ESenseConnectDialog> {
String eSenseDeviceName = '';
@override
Widget build(BuildContext context) {
return AlertDialog(
title: const Text('Connect to ESense'),
content: Column(mainAxisSize: MainAxisSize.min, children: [
TextField(
onChanged: (input) {
setState(() {
eSenseDeviceName = input;
});
},
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'eSense-xxxx',
labelText: 'Device name',
),
),
// Text(eSenseDeviceName),
ValueListenableBuilder(
valueListenable: widget.deviceStatus,
builder: (BuildContext context, String value, Widget? child) {
return Text(value);
}),
]),
actions: <Widget>[
TextButton(
onPressed: () => Navigator.pop(context, 'Cancel'),
child: const Text('Discard'),
),
TextButton(
onPressed: () => widget.connect(eSenseDeviceName),
child: const Text('Connect'),
),
],
);
}
}
|