checkPhoneExistence method
Implementation
Future<bool> checkPhoneExistence(String phone) async {
try {
var payload = {"email": "", "phone": phone};
var response = await Requests.getDio().post('auth/check-email', data: payload);
if (response.statusCode == 200) {
var data = response.data['data'];
bool phoneExists = data['phoneExist'] == true;
String message = "";
if (phoneExists) {
if (message.isNotEmpty) message += "\n";
message += "User with this phone number already exists.";
CustomFlashWidget.showFlashMessage(
type: FlashType.error,
title: "User Exists",
duration: Duration(seconds: 10),
message: message,
);
return true;
}else {
return false;
}
}
} catch (e) {
print("Error checking user existence: $e");
return false;
}
return false;
}