flutter - Flutter如何从firebase获取值日期时间(时间戳)到syncfusion日历
问题描述
Flutter如何从firebase获取值日期时间(时间戳)到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);
});
}
解决方案
TimeStamp.toDate()
从 firebase 时间戳转换为适当的DateTime
对象。
推荐阅读
- javascript - 有没有办法只调用一次 useEffect 并且还可以访问组件的当前状态?
- sql-server - 发布期间发生 ASP.NET Core 错误且站点无法正常工作
- c# - C# Sfml 我没有看到错误?
- apache - 使所有外部连接都无法访问服务器目录
- flutter - 圆形 BoxDecoration 阴影在网络上被切割成盒子形状,而不是在移动设备上
- mysql - 如何根据月份和年份计算 MySQL 上的总行数
- java - 使用 Apache POI 和丰富的文本 (HTML) 写入 docx
- sql - SQL Oracle:将两个表中的两列显示为一并计入数值的查询
- c - 控制到达非空函数错误的结尾
- swift - Apple Vision – 条码检测不适用于不同颜色的条码