Home > Net >  The argument type 'FirebaseAuthProvider' can't be assigned to the parameter type 
The argument type 'FirebaseAuthProvider' can't be assigned to the parameter type 

Time:06-24

Hello please help me am getting stack when creating an Auth Service with Flutter. and am  getting this error message 

'The argument type 'FirebaseAuthProvider' can't be assigned to the parameter type 'AuthService'

    import 'package:mynotes/service/auth_provider.dart';
    import 'package:mynotes/service/auth_user.dart';
    import 'package:mynotes/service/firebase_auth_provider.dart';
    
    class AuthService implements AuthProvider {
      final AuthService provider;
      const AuthService(this.provider);
      factory AuthService.firebase() => AuthService(FirebaseAuthProvider());
    
      // implement createUser
      @override
      Future<AuthUser> createUser({
        required String email,
        required String password,
      }) =>
          provider.createUser(
            email: email,
            password: password,
          );
    
      //implement currentUser
      @override
      AuthUser? get currentUser => provider.currentUser;
    
      //  implement login
      @override
      Future<AuthUser> login({
        required String email,
        required String password,
      }) =>
          provider.login(
            email: email,
            password: password,
          );
    
      // implement logout
      @override
      Future<void> logout() => provider.logout();
    
    // implement sendEmailVerification
      @override
      Future<void> sendEmailVerification() => provider.sendEmailVerification();
    
      @override
      Future<void> initialized() => provider.initialized();
    }

I have created an AuthService.dart page using flutter but when I use factory I get this error bellow The argument type 'FirebaseAuthProvider' can't be assigned to the parameter type 'AuthService'

CodePudding user response:

Change this line:

final AuthService provider;

to this:

final AuthProvider provider;

Please also see the GitHub repository for the Free Flutter Course to double check you implementation: https://github.com/vandadnp/mynotes-course

This specific file can be found here: https://github.com/vandadnp/mynotes-course/blob/8f021cbd58d4a4bb4d962ea2b085242b68bba989/lib/services/auth/auth_service.dart

  • Related