Home > Blockchain >  Flutter how to get value datetime (timestamp) from firebase to syncfusion calendar
Flutter how to get value datetime (timestamp) from firebase to syncfusion calendar

Time:10-29

Flutter how to get value datetime (timestamp) from firebase to syncfusion calendar

code https://drive.google.com/file/d/1F2q_bxVCkHwZrHOMZ4hN7FBIJR4IuEQ3/view?usp=sharing Image 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);
    });
  }

CodePudding user response:

TimeStamp.toDate() converts from a firebase timestamp to a proper DateTime object.

  • Related