deleteProfilePhoto method
Delete Profile Photo
Implementation
Future<void> deleteProfilePhoto() async {
await _handleAccountOperation(
operationName: 'Deleting profile photo',
successMessage: 'Your profile photo was deleted!',
customErrorMessage: 'Failed to delete profile photo',
closeOverlaysOnSuccess: true,
authOperation: () async {
String filePath =
'profile_pictures/${FirebaseAuth.instance.currentUser!.uid}/profile_picture.jpg';
Reference storageReference = FirebaseStorage
.instance
.ref()
.child('images')
.child(filePath);
await storageReference.delete();
await FirebaseAuth.instance.currentUser!
.updatePhotoURL('');
await FirebaseFirestore.instance
.collection('users')
.doc(FirebaseAuth.instance.currentUser!.uid)
.update({'imageUrl': ''});
},
);
}