gpt4 book ai didi

firebase - 意外文本 "return"

转载 作者:行者123 更新时间:2023-12-03 02:50:44 25 4
gpt4 key购买 nike

我正在尝试通过 Fireship ( https://fireship.io/lessons/flutter-firebase-google-oauth-firestore/ ) 教程实现 AuthService

我完全复制了他的 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({});
}
});
}

我收到这些错误:

enter image description here

enter image description here

如果我从他的网站上复制代码(完全一样),就没有错误。卧槽有人可以解释一下或提供帮助吗?谢谢!

最佳答案

改变这个:

    profile = user.switchMap((FirebaseUser u) => {

进入这个:

    profile = user.switchMap((FirebaseUser u) {

来自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.

关于firebase - 意外文本 "return",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57876743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com