当我的设备离线并尝试插入Firestore时,它将执行两次。
将我在adding document中的代码存储到Firestore。
答案 0 :(得分:1)
Firestore
不支持事务,离线模式的await
关键字都不支持,只需删除runTransaction并等待即可。
Future<void> saveHouseHolder() async {
CollectionReference reference = Firestore.instance
.collection('municipality')
.document(global.mundocid)
.collection('Barangay')
.document(global.brgydocid)
.collection('HouseHolderList');
reference.add({
'Name': name,
'Gender': gender,
'Age': age,
'Spouse': spouse,
'FullAddress': fullAdd,
// 'Location':new GeoPoint(latitude, longitude),
'ContactNumber': contactNo,
'Origin': origin,
'Language': language
});
Navigator.of(context).push(MaterialPageRoute(builder: (context) => HouseHolder()));
}
恢复连接后,它将自动同步。