Flutter如何从firebase获取值datetime(时间戳)到syncfusion日历

3phpmpom  于 2022-11-30  发布在  Flutter
关注(0)|答案(1)|浏览(124)

Flutter如何从firebase获取值datetime(时间戳)到syncfusion日历
代码https://drive.google.com/file/d/1F2q_bxVCkHwZrHOMZ4hN7FBIJR4IuEQ3/view?usp=sharing图像https://i.stack.imgur.com/aEMjH.png

Future<void> getDataFromFireStore() async {
    final now = DateTime.now().toUtc();
    var snapShotsValue = await databaseReference
        .collection("appointments")
        .doc("appointments")
        .collection('all')
        .get();

    final Random random = new Random();
    List<Meeting> list = snapShotsValue.docs
        .map((e) => Meeting(
            eventName: e.data()['description'],
            from: DateFormat('dd/MM/yyyy HH:mm:ss').parse(e.data()['date']),
            to: DateFormat('dd/MM/yyyy HH:mm:ss').parse(e.data()['date']),
            background: _colorCollection[random.nextInt(9)],
            isAllDay: false))
        .toList();

    setState(() {
      events = MeetingDataSource(list);
    });
  }
8wtpewkr

8wtpewkr1#

TimeStamp.toDate()从firebase时间戳转换为正确的DateTime对象。

相关问题