LCOV - code coverage report
Current view: top level - auth/middleware - sign_in_with_google_middleware.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 7 12 58.3 %
Date: 2022-03-03 12:16:56 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:redux/redux.dart';
       2             : 
       3             : import '../../../actions.dart';
       4             : import '../../../types.dart';
       5             : import '../../redux/extensions/store_extensions.dart';
       6             : import '../../utils/red_fire_locator.dart';
       7             : 
       8             : class SignInWithGoogleMiddleware<T extends RedFireState>
       9             :     extends TypedMiddleware<T, SignInWithGoogleAction> {
      10           1 :   SignInWithGoogleMiddleware()
      11           2 :       : super((store, action, next) async {
      12           1 :           next(action);
      13             : 
      14           1 :           final authService = RedFireLocator.getAuthService();
      15             : 
      16             :           try {
      17           1 :             store.dispatch(
      18             :                 const SetAuthStepAction(AuthStepEnum.contactingGoogle));
      19             : 
      20           1 :             final credential = await authService.getGoogleCredential();
      21             : 
      22             :             // If user cancelled sign in, reset UI and return
      23             :             if (credential == null) {
      24           0 :               store.dispatch(
      25             :                   const SetAuthStepAction(AuthStepEnum.waitingForInput));
      26             :               return;
      27             :             }
      28             : 
      29           0 :             store.dispatch(
      30             :                 const SetAuthStepAction(AuthStepEnum.signingInWithFirebase));
      31             : 
      32             :             // The authStateChanges stream will emit the same AuthUserData and
      33             :             // we are already listening to that stream and updating the app state
      34             :             // with whatever gets emitted.
      35             :             final authUserData =
      36           0 :                 await authService.signInWithGoogle(credential: credential);
      37             : 
      38           0 :             store.dispatch(SetAuthUserDataAction(authUserData));
      39           0 :             store.dispatch(
      40             :                 const SetAuthStepAction(AuthStepEnum.waitingForInput));
      41             :           } catch (error, trace) {
      42           1 :             store.dispatchProblem(error, trace);
      43             :           }
      44             :         });
      45             : }

Generated by: LCOV version 1.13