signup method

Future<bool> signup()

Implementation

Future<bool> signup() async {
  if (userController.text.isEmpty) {
    throw Exception("Email or phone is required");
  }
  if (nameController.text.isEmpty) {
    throw Exception("Name is required");
  }
  if (passwordController.text.isEmpty) {
    throw Exception("Password is required");
  }

  try {
    var data = await NetworkHandler.createAccount(
        name: nameController.text,
        email: userController.text,
        password: passwordController.text);
    if (data.containsKey('errorcode')) {
      throw Exception(data['reason']);
    }
    return true;
  } catch (error) {
    throw Exception(error.toString());
  }
}