Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
auth_notifier.dart
Go to the documentation of this file.
1import 'dart:async';
2import 'package:flutter/material.dart';
3import '../../features/auth/presentation/bloc/authentication_bloc/authentication_bloc.dart';
4import '../services/fast_sign_in_service.dart';
5
7 final AuthenticationBloc _authBloc;
9 late final StreamSubscription<AuthenticationState> _subscription;
10 bool _isAuthenticated = false;
11
12 AuthNotifier(this._authBloc) {
13 _isAuthenticated = _authBloc.state is AuthenticatedState;
14
15 _subscription = _authBloc.stream.listen((state) {
16 final wasAuthenticated = _isAuthenticated;
17 _isAuthenticated = state is AuthenticatedState;
18
19 if (wasAuthenticated != _isAuthenticated) {
20 notifyListeners();
21 }
22 });
23
24 // Also listen to fast sign-in state changes
25 _fastSignInService.isFastSignInActive
26 .addListener(_onFastSignInStateChanged);
27 }
28
30 notifyListeners();
31 }
32
34
35 @override
36 void dispose() {
37 _subscription.cancel();
38 _fastSignInService.isFastSignInActive
39 .removeListener(_onFastSignInStateChanged);
40 super.dispose();
41 }
42}
final AuthenticationBloc _authBloc
override void dispose()
void _onFastSignInStateChanged()
bool get isAuthenticated
final FastSignInService _fastSignInService
late final StreamSubscription< AuthenticationState > _subscription
AuthNotifier(this._authBloc)
String get(String locale)