onDocumentWrittenWithAuthContext method
void
onDocumentWrittenWithAuthContext(
- Future<
void> handler(), { - @mustBeConst required String document,
- @mustBeConst DocumentOptions? options,
Event handler that triggers on any write to a document (create, update, or delete), with authentication context.
Similar to onDocumentWritten, but the handler receives a FirestoreAuthEvent that includes AuthType and an optional auth ID.
Example:
firebase.firestore.onDocumentWrittenWithAuthContext(
document: 'users/{userId}',
(event) async {
print('Auth type: ${event.authType}');
print('Auth ID: ${event.authId}');
final before = event.data?.before;
final after = event.data?.after;
},
);
Implementation
void onDocumentWrittenWithAuthContext(
Future<void> Function(
FirestoreAuthEvent<Change<EmulatorDocumentSnapshot>?> event,
)
handler, {
// ignore: experimental_member_use
@mustBeConst required String document,
// ignore: experimental_member_use
@mustBeConst DocumentOptions? options,
}) {
_registerChangeHandler(
methodName: 'onDocumentWrittenWithAuthContext',
document: document,
validateEventType: _isFirestoreWrittenEvent,
withAuthContext: true,
handler: handler,
);
}