I'm trying to implement an AuthService from a tutorial of Fireship (https://fireship.io/lessons/flutter-firebase-google-oauth-firestore/)
I copied exactly his AuthService:
AuthService() {
user = Observable(_auth.onAuthStateChanged);
profile = user.switchMap((FirebaseUser u) => {
if (u != null) {
return _db.collection("users").document(u.uid).snapshots().map((snap) => snap.data);
} else {
return Observable.just({});
}
});
}
I get these errors:


If I copy the code from his website (it's exactly the same) there are no errors. wtf? Can someone explain this or help? Thanks!
Change this:
profile = user.switchMap((FirebaseUser u) => {
into this:
profile = user.switchMap((FirebaseUser u) {
From the docs:
For functions that contain just one expression, you can use a shorthand syntax:
bool isNoble(int atomicNumber) => _nobleGases[atomicNumber] != null;The
=>expr syntax is a shorthand for { return expr; }. The=>notation is sometimes referred to as arrow syntax.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With