@@ -17,30 +17,33 @@ class _CartAddRemoveButtonState extends State<CartAddRemoveButton> {
17
17
}
18
18
19
19
void onAddClicked () {
20
- setState (() {
21
- count = count + 1 ;
22
- print ("add clicked " + count.toString ());
23
- });
20
+ if (count < 4 )
21
+ setState (() {
22
+ count = count + 1 ;
23
+ print ("add clicked " + count.toString ());
24
+ });
24
25
}
25
26
26
27
void onRemoveClicked () {
27
- setState (() {
28
- count = count - 1 ;
29
- print ("remove clicked " + count.toString ());
30
- });
28
+ if (count > 0 )
29
+ setState (() {
30
+ count = count - 1 ;
31
+ print ("remove clicked " + count.toString ());
32
+ });
31
33
}
32
34
33
35
@override
34
36
Widget build (BuildContext context) {
35
37
return Container (
36
38
width: 96 ,
37
- height: 36 ,
39
+ height: 40 ,
38
40
decoration: ShapeDecoration (
39
41
shape: RoundedRectangleBorder (
40
42
borderRadius: BorderRadius .all (Radius .circular (10 )),
41
43
side: BorderSide (color: wood_smoke, width: 2 ))),
42
44
child: Row (
43
45
mainAxisSize: MainAxisSize .max,
46
+ crossAxisAlignment: CrossAxisAlignment .center,
44
47
children: < Widget > [
45
48
count == 0
46
49
? SizedBox ()
@@ -50,24 +53,31 @@ class _CartAddRemoveButtonState extends State<CartAddRemoveButton> {
50
53
onTap: () {
51
54
onRemoveClicked ();
52
55
},
53
- child: Center (
54
- child: IconButton (
55
- alignment: Alignment .topCenter,
56
- icon: Icon (Icons .remove),
57
- onPressed: () {
58
- onRemoveClicked ();
59
- },
56
+ child: IconButton (
57
+ icon: Icon (
58
+ Icons .remove,
59
+ size: 24 ,
60
60
),
61
+ onPressed: () {
62
+ onRemoveClicked ();
63
+ },
61
64
),
62
65
),
63
66
),
64
67
count == 0
65
68
? Expanded (
66
69
flex: 2 ,
67
70
child: Container (
71
+ padding: EdgeInsets .symmetric (horizontal: 8 ),
68
72
alignment: Alignment .center,
69
73
height: MediaQuery .of (context).size.height,
70
- color: lightening_yellow,
74
+ decoration: ShapeDecoration (
75
+ color: lightening_yellow,
76
+ shape: RoundedRectangleBorder (
77
+ borderRadius: BorderRadius .only (
78
+ topLeft: Radius .circular (10 ),
79
+ bottomLeft: Radius .circular (10 ))),
80
+ ),
71
81
child: Text (
72
82
"Add" ,
73
83
textAlign: TextAlign .center,
@@ -79,6 +89,7 @@ class _CartAddRemoveButtonState extends State<CartAddRemoveButton> {
79
89
: Expanded (
80
90
flex: 1 ,
81
91
child: Container (
92
+ padding: EdgeInsets .symmetric (horizontal: 8 ),
82
93
alignment: Alignment .center,
83
94
height: MediaQuery .of (context).size.height,
84
95
color: lightening_yellow,
@@ -95,19 +106,14 @@ class _CartAddRemoveButtonState extends State<CartAddRemoveButton> {
95
106
onTap: () {
96
107
onAddClicked ();
97
108
},
98
- child: Container (
99
- alignment: Alignment .topCenter,
100
- color: white,
101
- height: MediaQuery .of (context).size.height,
102
- child: Center (
103
- child: IconButton (
104
- alignment: Alignment .topCenter,
105
- icon: Icon (Icons .add),
106
- onPressed: () {
107
- onAddClicked ();
108
- },
109
- ),
109
+ child: IconButton (
110
+ icon: Icon (
111
+ Icons .add,
112
+ size: 24 ,
110
113
),
114
+ onPressed: () {
115
+ onAddClicked ();
116
+ },
111
117
),
112
118
),
113
119
)
0 commit comments