pollQuestionValidationError method

  1. @override
String? pollQuestionValidationError(
  1. int length,
  2. Range<int> range
)

The error shown when the poll question length is not within the range.

Returns 'Question must be a least ${range.min} characters long' if the question is too short and 'Question must be at most ${range.max} characters long' if the question is too long.

Implementation

@override
String? pollQuestionValidationError(int length, Range<int> range) {
  final (:min, :max) = range;

  // Check if the question is too short.
  if (min != null && length < min) {
    return 'La question doit comporter au moins $min caractères';
  }

  // Check if the question is too long.
  if (max != null && length > max) {
    return 'La question doit comporter au plus $max caractères';
  }

  return null;
}