/
main.dart
105 lines (101 loc) · 3.29 KB
/
main.dart
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import 'package:flutter/material.dart';
import 'package:quantity_input/quantity_input.dart';
void main() {
runApp(QuantityInputSample());
}
class QuantityInputSample extends StatefulWidget {
@override
State<QuantityInputSample> createState() => _QuantityInputSampleState();
}
class _QuantityInputSampleState extends State<QuantityInputSample> {
int simpleIntInput = 1;
int steppedIntInput = 1;
double simpleDoubleInput = 1;
double steppedDoubleInput = 1;
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text('Example')
),
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
QuantityInput(
label: 'Simple int input',
value: simpleIntInput,
onChanged: (value) => setState(() => simpleIntInput = int.parse(value.replaceAll(',', '')))
),
Text(
'Value: $simpleIntInput',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold
)
),
SizedBox(
height: 20
),
QuantityInput(
label: 'Int input with 3 step',
value: steppedIntInput,
step: 3,
onChanged: (value) => setState(() => steppedIntInput = int.parse(value.replaceAll(',', '')))
),
Text(
'Value: $steppedIntInput',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold
)
),
SizedBox(
height: 20
),
QuantityInput(
label: 'Simple double input',
type: QuantityInputType.double,
value: simpleDoubleInput,
decimalDigits: 1,
onChanged: (value) => setState(() => simpleDoubleInput = double.parse(value.replaceAll(',', '')))
),
Text(
'Value: $simpleDoubleInput',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold
)
),
SizedBox(
height: 20
),
QuantityInput(
label: 'Double input with 1.5 step',
type: QuantityInputType.double,
value: steppedDoubleInput,
step: 1.5,
decimalDigits: 1,
onChanged: (value) => setState(() => steppedDoubleInput = double.parse(value.replaceAll(',', '')))
),
Text(
'Value: $steppedDoubleInput',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold
)
)
]
)
)
)
)
);
}
}