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});
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.
2.1m questions
2.1m answers
60 comments
57.0k users