LCOV - code coverage report
Current view: top level - lib/data/repositories/authentication - app_user_repository_impl.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 10 10 100.0 %
Date: 2020-06-26 11:36:11 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:app_pym/core/network/network_info.dart';
       2             : import 'package:app_pym/data/datasources/map_pym_local_data_source.dart';
       3             : import 'package:app_pym/data/datasources/map_pym_remote_data_source.dart';
       4             : import 'package:app_pym/data/models/authentication/app_user_model.dart';
       5             : import 'package:app_pym/data/services/authentication_service.dart';
       6             : import 'package:app_pym/domain/entities/authentication/app_user.dart';
       7             : import 'package:app_pym/domain/repositories/authentication/app_user_repository.dart';
       8             : import 'package:connectivity/connectivity.dart';
       9             : import 'package:flutter/foundation.dart';
      10             : import 'package:injectable/injectable.dart';
      11             : 
      12             : @prod
      13             : @LazySingleton(as: AppUserRepository)
      14             : class AppUserRepositoryImpl implements AppUserRepository {
      15             :   final AuthenticationService auth;
      16             :   final MapPymRemoteDataSource remoteDataSource;
      17             :   final MapPymLocalDataSource localDataSource;
      18             :   final NetworkInfo networkInfo;
      19             : 
      20           1 :   AppUserRepositoryImpl({
      21             :     @required this.auth,
      22             :     @required this.localDataSource,
      23             :     @required this.remoteDataSource,
      24             :     @required this.networkInfo,
      25             :   });
      26             : 
      27             :   @override
      28           1 :   Future<AppUser> fetch() async {
      29           4 :     print("TOKEN ${auth.token}");
      30           2 :     if (auth.token != null) {
      31           4 :       if (await networkInfo.result != ConnectivityResult.none) {
      32           5 :         final data = await remoteDataSource.fetchUser(auth.token);
      33           3 :         await localDataSource.cacheUser(data);
      34           1 :         return data?.toEntity();
      35             :       } else {
      36           2 :         final data = localDataSource.fetchUser();
      37           1 :         return data?.toEntity();
      38             :       }
      39             :     } else {
      40             :       return null;
      41             :     }
      42             :   }
      43             : }

Generated by: LCOV version 1.13