Gokul Shivappa ๐Ÿš€
ย ยทย Your go-to FlutterFlow partner.

User Delete Action

Here is the simple action to delete user from admin Panel..

import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';

Future<void> deleteUser(String uid) async {
  try {
    // Delete the user document from Firestore
    await FirebaseFirestore.instance.collection('users').doc(uid).delete();

    // Delete the user from FirebaseAuth
    await FirebaseAuth.instance.currentUser!.delete();

    print('User deleted successfully');
  } catch (e) {
    throw Exception('Error while deleting the user: $e');
  }
}
11
9 replies