简体   繁体   English

我在 getuserinformation 中的 DataSnapShot 中遇到错误

[英]I am getting error in my DataSnapShot in getuserinformation

here is the code这是代码

     static void getCurrentOnlineUserInformation()async{
  User user = _firebaseAuth.currentUser;
  String userid = user.uid;
  DatabaseReference reference = FirebaseDatabase.instance.ref().child('userProfile');
  reference.child(userid).once().then((DataSnapshot dataSnapshot){
  }
  );
  }

but its not fetching DataSnapShot但它没有获取 DataSnapShot

Error error: The argument type 'Null Function(DataSnapshot)' can't be assigned to the parameter type 'FutureOr Function(DatabaseEvent)'.错误错误:无法将参数类型“Null Function(DataSnapshot)”分配给参数类型“FutureOr Function(DatabaseEvent)”。 (argument_type_not_assignable at [themovers] lib\assistants\assistantmethods.dart:86) (argument_type_not_assignable 在 [themovers] lib\assistants\assistantmethods.dart:86)

its getting null value again and again它一次又一次地获得 null 值

here is live code error这是实时代码错误

here is database这是数据库

here is the model这是 model

By default.then accepts dynamic parameter but if you wish to pass different parameter then you have change Function(dynamic) to Function(YOURTYPE) try below code:默认情况下.then 接受动态parameter ,但如果您希望传递不同的parameter ,那么您必须将Function(dynamic)更改为Function(YOURTYPE)尝试以下代码:

static void getCurrentOnlineUserInformation()async{
  User user = _firebaseAuth.currentUser;
  String userid = user.uid;
  DatabaseReference reference = 
        FirebaseDatabase.instance.ref().child('userProfile');
         reference.child(userid).once().then(<DataSnapshot>(DataSnapshot dataSnapshot){
        }
      );
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM