-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathnumber_property.dart
More file actions
43 lines (37 loc) · 1.11 KB
/
number_property.dart
File metadata and controls
43 lines (37 loc) · 1.11 KB
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
import 'package:dashbook/dashbook.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class NumberProperty extends StatefulWidget {
final Property<double> property;
final PropertyChanged onChanged;
const NumberProperty({
required this.property,
required this.onChanged,
super.key,
});
@override
State<StatefulWidget> createState() =>
NumberPropertyState(property.getValue());
}
class NumberPropertyState extends State<NumberProperty> {
TextEditingController controller = TextEditingController();
NumberPropertyState(double value) {
controller.text = value.toString();
}
@override
Widget build(BuildContext context) {
return PropertyScaffold(
tooltipMessage: widget.property.tooltipMessage,
label: widget.property.name,
child: TextField(
keyboardType: TextInputType.number,
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
onChanged: (value) {
widget.property.value = double.tryParse(value);
widget.onChanged();
},
controller: controller,
),
);
}
}