What is the difference between the two constructors?

Viewed 46

What is the difference between the constructors?

    class UserRepository {
    final FirebaseAuth _firebaseAuth;
    final GoogleSignIn _googleSignIn;

    UserRepository({FirebaseAuth firebaseAuth, GoogleSignIn googleSignin})
  : _firebaseAuth = firebaseAuth ?? FirebaseAuth.instance,
    _googleSignIn = googleSignin ?? GoogleSignIn();
    }

VERSUS

class UserRepository {
final FirebaseAuth _firebaseAuth;
final GoogleSignIn _googleSignIn;

UserRepository({this._firebaseAuth, this._googleSignin});
1 Answers

Briefly, on the above function, the default values are assigned when the constructor parameter are null. So It always has default value. (The ?? operator). While the below one is not.

Related