Firebase 在何处初始化';在颤振的initState()中需要什么?

Firebase 在何处初始化';在颤振的initState()中需要什么?,firebase,flutter,Firebase,Flutter,我对以下方法有兴趣: getCalendarEventList() async { print('here we go agsain'); await Firestore.instance.collection('availableDates').where('bandId', isEqualTo: identifier).snapshots().listen( (data) => data.documents.forEach((doc) =&g

我对以下方法有兴趣:

 getCalendarEventList() async {
    print('here we go agsain');
     await Firestore.instance.collection('availableDates').where('bandId', isEqualTo: identifier).snapshots().listen(
            (data) => data.documents.forEach((doc) => _markedDateMap.add(
            doc['availableDates'].toDate(),
            Event(
                date:doc['availableDates'].toDate(),
                title: 'hello',
                icon: _presentIcon(doc['availableDates'].toDate().day.toString())))));
    setState(() {});
  }
firebase
查询包含
isEqualTo:identifier
作为条件
Identifier
是一个
字符串
,它实际上是用户的Firebase
uid
。getCalendarEventList()是在
initState()中调用的:因为我希望用标记填充

@override
  void initState() {
    super.initState();
    getCalendarEventList();
  }
我有一个方法:获取
firebase
uid

Future<String> inputData() async {
    final FirebaseUser user = await FirebaseAuth.instance.currentUser();
    final String uid = user.uid.toString();
    return uid;
  }
Future inputData()异步{
final FirebaseUser user=等待FirebaseAuth.instance.currentUser();
最后一个字符串uid=user.uid.toString();
返回uid;
}

我已经把
identifier=await inputData()getCalendarEventList()
中的code>和9/10倍的标记填充日历…(来自
initState()
),因此有点“错误”…我认为这与从Firebase调用uid有关。我应该在何处/如何使用
firebase uid
初始化变量
identifier

您可以调用标识符,然后在完成后,您可以调用
GetCalendarEvents()


仍然是相同的问题。但可能这不是问题所在。在
getCalenderEvents()中,添加到
\u markedDateMap
的问题日期到底是什么
和该类围绕日历ui。它间歇性地工作。
   await FirebaseAuth.instance.currentUser().then((user) {
     Firestore.instance.collection('availableDates').where('bandId', isEqualTo: user.uid).snapshots().listen(
            (data) => data.documents.forEach((doc) => _markedDateMap.add(
            doc['availableDates'].toDate(),
            Event(
                date:doc['availableDates'].toDate(),
                title: 'hello',
                icon: _presentIcon(doc['availableDates'].toDate().day.toString())))));
    setState(() {});
    }).catchError((onError){
    handleError();
   });
   await FirebaseAuth.instance.currentUser().then((user) {
    setState(() {
    identifier = user.uid;
   });
    getCalenderEvents();
    }).catchError((onError){
    handleError();
   });