main
1import 'package:blood_pressure_app/components/input_dialoge.dart';
2import 'package:flutter/material.dart';
3
4/// A list tile for exposing editable strings.
5class InputListTile extends StatelessWidget {
6 /// Creates a list tile that allows editing a string.
7 const InputListTile({super.key,
8 required this.label,
9 required this.value,
10 required this.onSubmit,});
11
12 /// Short label describing the required field contents.
13 ///
14 /// This will be both the title of the list tile as well as the hint text in the input dialoge.
15 final String label;
16
17 /// Current content of the input field.
18 final String value;
19
20 /// Gets called when the user submits a new value
21 final void Function(String text) onSubmit;
22
23 @override
24 Widget build(BuildContext context) => ListTile(
25 title: Text(label),
26 subtitle: Text(value),
27 trailing: const Icon(Icons.edit),
28 onTap: () async {
29 final input = await showInputDialoge(context, initialValue: value, hintText: label);
30 if (input != null) onSubmit(input);
31 },
32 );
33
34}