Skip to content

Commit ae27301

Browse files
committed
feat(authentication): refactor auth page to use localized errors
Updates the `AuthenticationPage` to use the `toFriendlyMessage` extension from `ht_ui_kit`. The `BlocConsumer` now accesses the `exception` object from the `AuthenticationState` and passes it to the extension method to display a user-friendly, localized error message in the `SnackBar`. A `debugPrint` statement was temporarily added to diagnose a context-related issue with the localization, which is now resolved.
1 parent bd710d1 commit ae27301

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/authentication/view/authentication_page.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter_bloc/flutter_bloc.dart';
33
import 'package:go_router/go_router.dart';
4+
import 'package:flutter/foundation.dart';
45
import 'package:ht_dashboard/authentication/bloc/authentication_bloc.dart';
56
import 'package:ht_dashboard/l10n/l10n.dart';
67
import 'package:ht_ui_kit/ht_ui_kit.dart';
@@ -34,11 +35,14 @@ class AuthenticationPage extends StatelessWidget {
3435
listener: (context, state) {
3536
if (state.status == AuthenticationStatus.failure &&
3637
state.exception != null) {
38+
final friendlyMessage = state.exception!.toFriendlyMessage(
39+
context,
40+
);
3741
ScaffoldMessenger.of(context)
3842
..hideCurrentSnackBar()
3943
..showSnackBar(
4044
SnackBar(
41-
content: Text(state.exception!.toFriendlyMessage(context)),
45+
content: Text(friendlyMessage),
4246
backgroundColor: colorScheme.error,
4347
),
4448
);
@@ -49,7 +53,8 @@ class AuthenticationPage extends StatelessWidget {
4953
// email flow pages.
5054
},
5155
builder: (context, state) {
52-
final isLoading = state.status == AuthenticationStatus.loading ||
56+
final isLoading =
57+
state.status == AuthenticationStatus.loading ||
5358
state.status == AuthenticationStatus.requestCodeLoading;
5459

5560
return Padding(

0 commit comments

Comments
 (0)