【问题标题】:The argument type 'User' can't be assigned to the parameter type 'Future<dynamic>'参数类型“用户”不能分配给参数类型“未来<动态>”
【发布时间】:2021-02-16 18:20:57
【问题描述】:

我正在尝试构建一个包含聊天的应用程序,但出现错误消息是因为这行:

 return FutureBuilder(
      future: FirebaseAuth.instance.currentUser,
The argument type 'User' can't be assigned to the parameter type 'Future<dynamic>'.

我的代码 enter image description here

【问题讨论】:

    标签: firebase flutter firebase-authentication chat flutter-futurebuilder


    【解决方案1】:

    currentUser 是一个属性,它返回一个User 类型的值,因此您不必将它分配给future 属性,只需这样做:

    User user = FirebaseAuth.instance.currentUser;
    

    【讨论】:

    • 但是我应该在 "future:" ,,,, FutureBuilder(future: ....) 中写什么
    • Nothing 不使用 FutureBuilder,因为 currentUser 是同步的立即给出结果
    猜你喜欢
    • 2021-09-18
    • 1970-01-01
    • 2021-08-27
    • 2022-01-05
    • 1970-01-01
    • 2021-09-10
    • 2021-09-21
    • 1970-01-01
    • 2021-01-05
    相关资源
    最近更新 更多