11import 'dart:async' ;
22
3+ import 'package:auth_repository/auth_repository.dart' ;
34import 'package:bloc/bloc.dart' ;
4- import 'package:equatable/equatable.dart' ;
5- import 'package:ht_auth_repository/ht_auth_repository.dart' ;
6- import 'package:ht_shared/ht_shared.dart'
5+ import 'package:core/core.dart'
76 show
87 AuthenticationException,
98 ForbiddenException,
10- HtHttpException ,
9+ HttpException ,
1110 InvalidInputException,
1211 NetworkException,
1312 NotFoundException,
@@ -16,6 +15,7 @@ import 'package:ht_shared/ht_shared.dart'
1615 UnauthorizedException,
1716 UnknownException,
1817 User;
18+ import 'package:equatable/equatable.dart' ;
1919
2020part 'authentication_event.dart' ;
2121part 'authentication_state.dart' ;
@@ -26,7 +26,7 @@ part 'authentication_state.dart';
2626class AuthenticationBloc
2727 extends Bloc <AuthenticationEvent , AuthenticationState > {
2828 /// {@macro authentication_bloc}
29- AuthenticationBloc ({required HtAuthRepository authenticationRepository})
29+ AuthenticationBloc ({required AuthRepository authenticationRepository})
3030 : _authenticationRepository = authenticationRepository,
3131 super (const AuthenticationState ()) {
3232 // Listen to authentication state changes from the repository
@@ -42,7 +42,7 @@ class AuthenticationBloc
4242 on < AuthenticationSignOutRequested > (_onAuthenticationSignOutRequested);
4343 }
4444
45- final HtAuthRepository _authenticationRepository;
45+ final AuthRepository _authenticationRepository;
4646 late final StreamSubscription <User ?> _userAuthSubscription;
4747
4848 /// Handles [_AuthenticationStatusChanged] events.
@@ -85,55 +85,20 @@ class AuthenticationBloc
8585 ),
8686 );
8787 } on InvalidInputException catch (e) {
88- emit (
89- state.copyWith (
90- status: AuthenticationStatus .failure,
91- exception: e,
92- ),
93- );
88+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
9489 } on UnauthorizedException catch (e) {
95- emit (
96- state.copyWith (
97- status: AuthenticationStatus .failure,
98- exception: e,
99- ),
100- );
90+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
10191 } on ForbiddenException catch (e) {
102- emit (
103- state.copyWith (
104- status: AuthenticationStatus .failure,
105- exception: e,
106- ),
107- );
92+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
10893 } on NetworkException catch (e) {
109- emit (
110- state.copyWith (
111- status: AuthenticationStatus .failure,
112- exception: e,
113- ),
114- );
94+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
11595 } on ServerException catch (e) {
116- emit (
117- state.copyWith (
118- status: AuthenticationStatus .failure,
119- exception: e,
120- ),
121- );
96+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
12297 } on OperationFailedException catch (e) {
123- emit (
124- state.copyWith (
125- status: AuthenticationStatus .failure,
126- exception: e,
127- ),
128- );
129- } on HtHttpException catch (e) {
130- // Catch any other HtHttpException subtypes
131- emit (
132- state.copyWith (
133- status: AuthenticationStatus .failure,
134- exception: e,
135- ),
136- );
98+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
99+ } on HttpException catch (e) {
100+ // Catch any other HttpException subtypes
101+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
137102 } catch (e) {
138103 // Catch any other unexpected errors
139104 emit (
@@ -161,55 +126,20 @@ class AuthenticationBloc
161126 // On success, the _AuthenticationStatusChanged listener will handle
162127 // emitting AuthenticationAuthenticated.
163128 } on InvalidInputException catch (e) {
164- emit (
165- state.copyWith (
166- status: AuthenticationStatus .failure,
167- exception: e,
168- ),
169- );
129+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
170130 } on AuthenticationException catch (e) {
171- emit (
172- state.copyWith (
173- status: AuthenticationStatus .failure,
174- exception: e,
175- ),
176- );
131+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
177132 } on NotFoundException catch (e) {
178- emit (
179- state.copyWith (
180- status: AuthenticationStatus .failure,
181- exception: e,
182- ),
183- );
133+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
184134 } on NetworkException catch (e) {
185- emit (
186- state.copyWith (
187- status: AuthenticationStatus .failure,
188- exception: e,
189- ),
190- );
135+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
191136 } on ServerException catch (e) {
192- emit (
193- state.copyWith (
194- status: AuthenticationStatus .failure,
195- exception: e,
196- ),
197- );
137+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
198138 } on OperationFailedException catch (e) {
199- emit (
200- state.copyWith (
201- status: AuthenticationStatus .failure,
202- exception: e,
203- ),
204- );
205- } on HtHttpException catch (e) {
206- // Catch any other HtHttpException subtypes
207- emit (
208- state.copyWith (
209- status: AuthenticationStatus .failure,
210- exception: e,
211- ),
212- );
139+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
140+ } on HttpException catch (e) {
141+ // Catch any other HttpException subtypes
142+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
213143 } catch (e) {
214144 // Catch any other unexpected errors
215145 emit (
@@ -233,34 +163,14 @@ class AuthenticationBloc
233163 // On success, the _AuthenticationStatusChanged listener will handle
234164 // emitting AuthenticationUnauthenticated.
235165 } on NetworkException catch (e) {
236- emit (
237- state.copyWith (
238- status: AuthenticationStatus .failure,
239- exception: e,
240- ),
241- );
166+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
242167 } on ServerException catch (e) {
243- emit (
244- state.copyWith (
245- status: AuthenticationStatus .failure,
246- exception: e,
247- ),
248- );
168+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
249169 } on OperationFailedException catch (e) {
250- emit (
251- state.copyWith (
252- status: AuthenticationStatus .failure,
253- exception: e,
254- ),
255- );
256- } on HtHttpException catch (e) {
257- // Catch any other HtHttpException subtypes
258- emit (
259- state.copyWith (
260- status: AuthenticationStatus .failure,
261- exception: e,
262- ),
263- );
170+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
171+ } on HttpException catch (e) {
172+ // Catch any other HttpException subtypes
173+ emit (state.copyWith (status: AuthenticationStatus .failure, exception: e));
264174 } catch (e) {
265175 emit (
266176 state.copyWith (
0 commit comments