@@ -31,29 +31,8 @@ class FeedbackScreen extends StatelessWidget {
31
31
body: BlocProvider (
32
32
create: (context) =>
33
33
FeedbackPageBloc (repo: context.read <FeedbackRepository >()),
34
- child: BlocBuilder <FeedbackPageBloc , FeedbackPageState >(
34
+ child: BlocConsumer <FeedbackPageBloc , FeedbackPageState >(
35
35
builder: (context, state) {
36
- if (state.error) {
37
- Fluttertoast .showToast (
38
- msg: "Unable to submit feedback!" ,
39
- toastLength: Toast .LENGTH_SHORT ,
40
- gravity: ToastGravity .BOTTOM ,
41
- timeInSecForIosWeb: 1 ,
42
- textColor: Colors .white,
43
- backgroundColor: AppTheme .red,
44
- fontSize: 16.0 );
45
- }
46
- if (state.submitted) {
47
- Fluttertoast .showToast (
48
- msg: "Feedback submitted successfully!" ,
49
- toastLength: Toast .LENGTH_SHORT ,
50
- gravity: ToastGravity .BOTTOM ,
51
- timeInSecForIosWeb: 1 ,
52
- textColor: Colors .white,
53
- backgroundColor: AppTheme .green,
54
- fontSize: 12. toAutoScaledFont);
55
- context.router.pop ();
56
- }
57
36
return Column (
58
37
children: [
59
38
const FeedbackBanner (),
@@ -124,6 +103,30 @@ class FeedbackScreen extends StatelessWidget {
124
103
alignment: Alignment .bottomRight,
125
104
child: BlackIconButton (
126
105
onTap: () {
106
+ for (var rating in state.rating) {
107
+ if (rating == 0 ) {
108
+ Fluttertoast .showToast (
109
+ msg: "Please rate all the categories!" ,
110
+ toastLength: Toast .LENGTH_SHORT ,
111
+ gravity: ToastGravity .BOTTOM ,
112
+ timeInSecForIosWeb: 1 ,
113
+ textColor: Colors .white,
114
+ backgroundColor: AppTheme .red,
115
+ fontSize: 12. toAutoScaledFont);
116
+ return ;
117
+ }
118
+ }
119
+ if (state.description.trim ().isEmpty) {
120
+ Fluttertoast .showToast (
121
+ msg: "Please describe your Feedback!" ,
122
+ toastLength: Toast .LENGTH_SHORT ,
123
+ gravity: ToastGravity .BOTTOM ,
124
+ timeInSecForIosWeb: 1 ,
125
+ textColor: Colors .white,
126
+ backgroundColor: AppTheme .red,
127
+ fontSize: 12. toAutoScaledFont);
128
+ return ;
129
+ }
127
130
context.read <FeedbackPageBloc >().add (
128
131
FeedbackPageSubmitEvent (
129
132
mealId: mealId,
@@ -143,6 +146,29 @@ class FeedbackScreen extends StatelessWidget {
143
146
],
144
147
);
145
148
},
149
+ listener: (BuildContext context, FeedbackPageState state) {
150
+ if (state.submitted) {
151
+ Fluttertoast .showToast (
152
+ msg: "Feedback submitted successfully!" ,
153
+ toastLength: Toast .LENGTH_SHORT ,
154
+ gravity: ToastGravity .BOTTOM ,
155
+ timeInSecForIosWeb: 1 ,
156
+ textColor: Colors .white,
157
+ backgroundColor: AppTheme .green,
158
+ fontSize: 12. toAutoScaledFont);
159
+ context.router.pop ();
160
+ }
161
+ if (state.error) {
162
+ Fluttertoast .showToast (
163
+ msg: "Unable to submit feedback!" ,
164
+ toastLength: Toast .LENGTH_SHORT ,
165
+ gravity: ToastGravity .BOTTOM ,
166
+ timeInSecForIosWeb: 1 ,
167
+ textColor: Colors .white,
168
+ backgroundColor: AppTheme .red,
169
+ fontSize: 16.0 );
170
+ }
171
+ },
146
172
),
147
173
),
148
174
);
0 commit comments