verifyUser method
Implementation
Future<bool> verifyUser(String type) async {
if (controller.text.isEmpty) {
throw Exception("Email or phone is required");
}
// if (!isEmailValid(controller.text)) {
// throw Exception("Invalid email");
// }
if (type == "email") {
try {
var data =
await NetworkHandler.verifyUser(email: controller.text, phone: "");
if (data.containsKey('errorcode')) {
throw Exception(data['reason']);
}
return data['success'];
} catch (error) {
throw Exception(error.toString());
}
} else if (type == "phone") {
try {
var data =
await NetworkHandler.verifyUser(email: "", phone: controller.text);
if (data.containsKey('errorcode')) {
throw Exception(data['reason']);
}
return data['success'];
} catch (error) {
throw Exception(error.toString());
}
} else {
throw Exception("Invalid type");
}
}