如何解决平台异常:无效的文档参考。文档引用必须具有偶数个段

时间:2019-02-06 20:11:21

标签: dart flutter google-cloud-firestore

我可以从下面的代码中成功获取用户名,但是却遇到了这个烦人的异常(PlatformException(错误,无效的文档引用。文档引用必须具有偶数个段,但是用户具有1,空值))。这是代码

    DocumentSnapshot snapshot = await _firestoreRecord
     .collection('users')
     .document(userId)
     .get();
    return snapshot.data['username'];

我尝试做await _firestoreRecord.document('users/' + userId)无济于事。

我做错什么了吗?谢谢

1 个答案:

答案 0 :(得分:0)

结果是我没有检查Firebase Auth中的用户是否为空。我添加了这个:

<ModuleRoute path="/module/:path" />
相关问题