writeData method
Writes data to a Firestore document via set
documentPath
: Path to the Firestore document.data
: The data to write.merge
: Whether to merge data with existing content (default:true
).
Returns true
if the operation is successful, false
otherwise.
Implementation
Future<bool> writeData(String documentPath, Map<String, dynamic> data, {bool merge = false}) async {
try {
await _firestore.doc(documentPath).set(data, SetOptions(merge: merge));
debugPrint('Document created or merged successfully.');
return true;
} catch (e) {
debugPrint('Error writing data to Firestore with set: $e');
return false;
}
}