(https://i.stack.imgur.com/GvVsx.png)我想将房间ID保存到右侧的房间详细信息中。
q3qa4bjr1#
您需要先获取房间ID,以便将数据设置为该ID,如下所示
Future<void> addCategory( BuildContext context, String categoryName, ) async { bool hasConnection = await NetworkConn.isInternet(); if (hasConnection) { String categoryId = category.doc().id;///this is the id return category.doc(categoryId).set({ 'id': categoryId,///this is the in feild 'CategoryName': categoryName, "AddedBy": user!.email, "CreatedAt: ": DateTime.now().toString(), }).then((value) { CustomDialog.showSuccessDialog(context, "Category Added"); }).catchError((error) { Logger().e("Failed to add user: $error"); CustomDialog.showErrorDialog(context, "Unable to add Category"); }); } else { CustomDialog.showErrorDialog(context, "Please Connect to Internet"); } }
1条答案
按热度按时间q3qa4bjr1#
您需要先获取房间ID,以便将数据设置为该ID,如下所示