【问题标题】:await not working with async in Flutter [Await applied to User which is not a Future] [duplicate]等待在 Flutter 中无法使用异步 [等待应用于不是未来的用户] [重复]
【发布时间】:2020-12-14 20:10:11
【问题描述】:

当我将 await 与 async 一起使用时,它要求我删除 await。这是什么原因?? 请检查图像,必须使用 async 和 await 与 Future 然后为什么它要求删除。我是这门语言的新手,请帮忙..谢谢。

我使用的是 firebase 版本 - firebase_auth: ^0.18.0+1

[1]: https://i.stack.imgur.com/arM35.png

【问题讨论】:

    标签: firebase flutter async-await firebase-authentication future


    【解决方案1】:

    await 在返回对象的未来时应用于表达式或变量,但在这里 FirebaseAuth.instance.currentUser 正在返回 User 而不是 Future 所以你不需要在这里使用 await 你仍然可以使用它,因为它只是一个警告而不是错误或异常 谢谢,希望对你有帮助

    【讨论】:

    • 从您的解释中,我的疑问得到了澄清,感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-06-29
    • 2021-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-18
    • 2016-07-07
    相关资源
    最近更新 更多