Skip to content

Commit 139347d

Browse files
committed
fix: stays on the screen in case of any error
1 parent de306db commit 139347d

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

lib/presentation/feedback/bloc/feedback_page_bloc.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class FeedbackPageBloc extends Bloc<FeedbackPageEvent, FeedbackPageState> {
8282
rating: state.rating,
8383
description: event.description,
8484
submitted: state.submitted,
85-
error: state.error,
85+
error: false,
8686
mealId: state.mealId,
8787
),
8888
);

lib/presentation/feedback/feedback_view.dart

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:appetizer/presentation/feedback/components/feedback_banner.dart'
99
import 'package:auto_route/auto_route.dart';
1010
import 'package:flutter/material.dart';
1111
import 'package:flutter_bloc/flutter_bloc.dart';
12+
import 'package:fluttertoast/fluttertoast.dart';
1213

1314
@RoutePage()
1415
class FeedbackScreen extends StatelessWidget {
@@ -32,6 +33,27 @@ class FeedbackScreen extends StatelessWidget {
3233
FeedbackPageBloc(repo: context.read<FeedbackRepository>()),
3334
child: BlocBuilder<FeedbackPageBloc, FeedbackPageState>(
3435
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+
}
3557
return Column(
3658
children: [
3759
const FeedbackBanner(),
@@ -101,14 +123,12 @@ class FeedbackScreen extends StatelessWidget {
101123
Align(
102124
alignment: Alignment.bottomRight,
103125
child: BlackIconButton(
104-
// onTap: context.router.pop,
105126
onTap: () {
106127
context.read<FeedbackPageBloc>().add(
107128
FeedbackPageSubmitEvent(
108129
mealId: mealId,
109130
rating: state.rating,
110131
description: state.description));
111-
context.router.pop();
112132
},
113133
title: "SUBMIT",
114134
width: 102.toAutoScaledWidth,

0 commit comments

Comments
 (0)