validateFields method

dynamic validateFields(
  1. String id, {
  2. bool fromDialog = false,
})

Implementation

validateFields(String id,{bool fromDialog = false}) {
  if (firstNameController.text.isEmpty) {
    DefaultSnackbar.show("First Name", "Please enter your first name");
    return false;
  } else if (lastNameController.text.isEmpty) {
    DefaultSnackbar.show("Last Name", "Please enter your last name");
    return false;
  } else if (selectedNationality.value.isEmpty) {
    DefaultSnackbar.show("Nationality", "Please select your nationality");
    return false;
  } else if (dobController.text.isEmpty) {
    DefaultSnackbar.show("Date of Birth", "Please select your date of birth");
    return false;
  } else if (selectedGender.value.isEmpty) {
    DefaultSnackbar.show("Gender", "Please select your gender");
    return false;
  } else if (passportNumberController.text.isEmpty &&
      passportNumberController.text.trim().length < 6) {
    DefaultSnackbar.show("Passport Number",
        "Please enter your passport number containing atleast 6 charcaters");
    return false;
  } else if (selectedCountry.value.isEmpty) {
    DefaultSnackbar.show("Passport Issuing Country",
        "Please select your Passport Issuing country");
    return false;
  } else if (passportExpiryController.text.isEmpty) {
    DefaultSnackbar.show(
        "Passport Expiry Date", "Please select your passport expiry date");
    return false;
  } else {
    if (fromDialog) {
      Get.back();
    }
    addPassenger(id);
  }
  return true;
}