validateWithSnack method

bool validateWithSnack(
  1. List<bool> conditions,
  2. List<String> errors
)

Validates multiple boolean conditions.

Displays the first matching error message using a snack bar and stops validation immediately.

Implementation

bool validateWithSnack(List<bool> conditions, List<String> errors) {
  for (var i = 0; i < conditions.length; i++) {
    if (!conditions[i]) {
      final error = errors.length > i ? errors[i] : errors.first;
      snack(error, success: false);
      return false;
    }
  }
  return true;
}