OtpCodeVerificationField constructor

const OtpCodeVerificationField({
  1. int numberOfDigits = 6,
  2. OtpCodeType? codeType,
  3. OtpCodeLetterCasing? codeLetterCasing,
  4. OtpCodeLetterSet? codeLetterSet,
  5. String customSet = '',
  6. bool autoFocus = true,
  7. ValueChanged<String>? onChanged,
  8. required Future<bool> onSubmit(
    1. String code
    ),
  9. bool showCountdown = true,
  10. required DateTime? countdownStartDateTime,
  11. Duration countdownDuration = const Duration(minutes: 30),
  12. required VoidCallback onExpiredGoBack,
  13. bool showWrongCodeMessage = true,
  14. String wrongCodeMessage = 'Enter the correct code',
  15. String verificationFailedMessageBuilder({
    1. Object? error,
    }) = defaultVerificationFailedMessageBuilder,
  16. String retryButtonLabel = 'Retry',
  17. String expiredMessage = 'Your code expired',
  18. String expiredButtonLabel = 'Go back to try again',
  19. String countdownTextBuilder({
    1. required int secondsCountdown,
    }) = defaultCountdownText,
  20. Widget countdownContainerBuilder({
    1. required Widget child,
    }) = defaultCountdownContainerBuilder,
  21. Widget errorContainerBuilder({
    1. required Widget child,
    }) = defaultErrorContainerBuilder,
  22. Widget digitContainerBuilder({
    1. required Color? activeBorderColor,
    2. required Color? backgroundColor,
    3. required Color? borderColor,
    4. required Widget child,
    5. required bool isCurrentDigit,
    }) = defaultDigitContainerBuilder,
  23. Widget buttonBuilder({
    1. required Color? backgroundColor,
    2. required String label,
    3. required VoidCallback onTap,
    4. required Color? textColor,
    5. required TextStyle? textStyle,
    })?,
  24. TextStyle? digitTextStyle,
  25. TextStyle? errorTextStyle,
  26. TextStyle? expiredTextStyle,
  27. TextStyle? countdownTextStyle,
  28. TextStyle? buttonTextStyle,
  29. Color? digitBackgroundColor,
  30. Color? digitBorderColor,
  31. Color? digitActiveBorderColor,
  32. Color? cursorColor,
  33. Size? cursorSize = const Size(3, 30),
  34. Color? buttonBackgroundColor,
  35. Color? buttonTextColor,
  36. bool debugShowTextField = false,
  37. Key? key,
})

Implementation

const OtpCodeVerificationField({
  this.numberOfDigits = 6,
  this.codeType,
  this.codeLetterCasing,
  this.codeLetterSet,
  this.customSet = '',
  this.autoFocus = true,
  this.onChanged,
  required this.onSubmit,
  this.showCountdown = true,
  required this.countdownStartDateTime,
  this.countdownDuration = const Duration(minutes: 30),
  required this.onExpiredGoBack,
  this.showWrongCodeMessage = true,
  this.wrongCodeMessage = 'Enter the correct code',
  this.verificationFailedMessageBuilder = defaultVerificationFailedMessageBuilder,
  this.retryButtonLabel = 'Retry',
  this.expiredMessage = 'Your code expired',
  this.expiredButtonLabel = 'Go back to try again',
  this.countdownTextBuilder = defaultCountdownText,
  this.countdownContainerBuilder = defaultCountdownContainerBuilder,
  this.errorContainerBuilder = defaultErrorContainerBuilder,
  this.digitContainerBuilder = defaultDigitContainerBuilder,
  this.buttonBuilder,
  this.digitTextStyle,
  this.errorTextStyle,
  this.expiredTextStyle,
  this.countdownTextStyle,
  this.buttonTextStyle,
  this.digitBackgroundColor,
  this.digitBorderColor,
  this.digitActiveBorderColor,
  this.cursorColor,
  this.cursorSize = const Size(3, 30),
  this.buttonBackgroundColor,
  this.buttonTextColor,
  this.debugShowTextField = false,
  super.key,
}) : assert(
       numberOfDigits >= 2 && numberOfDigits <= 50,
       'numberOfDigits must be in [2, 50]',
     ),
     assert(
       codeLetterSet != OtpCodeLetterSet.custom || customSet != '',
       'customSet must be non-empty when codeLetterSet is OtpCodeLetterSet.custom',
     ),
     // aToZ / unicodeLetters / custom are letter-portion sets — they
     // can't be combined with codeType=numbersOnly (no letters allowed).
     assert(
       (codeLetterSet != OtpCodeLetterSet.aToZ &&
               codeLetterSet != OtpCodeLetterSet.unicodeLetters &&
               codeLetterSet != OtpCodeLetterSet.custom) ||
           codeType != OtpCodeType.numbersOnly,
       'codeLetterSet aToZ / unicodeLetters / custom requires codeType '
       'to be lettersOnly, numbersAndLetters, or null',
     ),
     // binary is digits-only; codeType must be numbersOnly or null.
     assert(
       codeLetterSet != OtpCodeLetterSet.binary ||
           codeType == null ||
           codeType == OtpCodeType.numbersOnly,
       'codeLetterSet binary requires codeType to be numbersOnly or null',
     ),
     // crockford / hexadecimal / base62 mix digits and letters; codeType
     // must be numbersAndLetters or null.
     assert(
       (codeLetterSet != OtpCodeLetterSet.crockford &&
               codeLetterSet != OtpCodeLetterSet.hexadecimal &&
               codeLetterSet != OtpCodeLetterSet.base62) ||
           codeType == null ||
           codeType == OtpCodeType.numbersAndLetters,
       'codeLetterSet crockford / hexadecimal / base62 requires codeType '
       'to be numbersAndLetters or null',
     ),
     // base62 keeps both cases distinct; forced casing would defeat it.
     assert(
       codeLetterSet != OtpCodeLetterSet.base62 ||
           codeLetterCasing == null ||
           codeLetterCasing == OtpCodeLetterCasing.mixed,
       'codeLetterSet base62 requires codeLetterCasing to be mixed or null',
     );