feat: Centralized Error Handling & Crash Fixes
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import 'package:core_localization/core_localization.dart';
|
||||
import 'package:design_system/design_system.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
@@ -57,12 +58,11 @@ class _PhoneVerificationPageState extends State<PhoneVerificationPage> {
|
||||
AuthSignInRequested(phoneNumber: '+1$normalized', mode: widget.mode),
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
t.staff_authentication.phone_verification_page.validation_error,
|
||||
),
|
||||
),
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: t.staff_authentication.phone_verification_page.validation_error,
|
||||
type: UiSnackbarType.error,
|
||||
margin: const EdgeInsets.only(bottom: 180, left: 16, right: 16),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -110,14 +110,11 @@ class _PhoneVerificationPageState extends State<PhoneVerificationPage> {
|
||||
final String messageKey = state.errorMessage ?? '';
|
||||
// Handle specific business logic errors for signup
|
||||
if (messageKey == 'errors.auth.account_exists') {
|
||||
final ScaffoldMessengerState messenger =
|
||||
ScaffoldMessenger.of(context);
|
||||
messenger.hideCurrentSnackBar();
|
||||
messenger.showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(translateErrorKey(messageKey)),
|
||||
duration: const Duration(seconds: 5),
|
||||
),
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: translateErrorKey(messageKey),
|
||||
type: UiSnackbarType.error,
|
||||
margin: const EdgeInsets.only(bottom: 180, left: 16, right: 16),
|
||||
);
|
||||
Future<void>.delayed(const Duration(seconds: 5), () {
|
||||
if (!mounted) return;
|
||||
|
||||
@@ -96,13 +96,11 @@ class _ProfileSetupPageState extends State<ProfileSetupPage> {
|
||||
if (state.status == ProfileSetupStatus.success) {
|
||||
Modular.to.toStaffHome();
|
||||
} else if (state.status == ProfileSetupStatus.failure) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
state.errorMessage ??
|
||||
t.staff_authentication.profile_setup_page.error_occurred,
|
||||
),
|
||||
),
|
||||
UiSnackbar.show(
|
||||
context,
|
||||
message: translateErrorKey(state.errorMessage ?? t.staff_authentication.profile_setup_page.error_occurred),
|
||||
type: UiSnackbarType.error,
|
||||
margin: const EdgeInsets.only(bottom: 150, left: 16, right: 16),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user