onSubmit property

Future<bool> Function(String code) onSubmit
final

Called once all numberOfDigits characters have been entered, with the typed code. The widget itself dismisses the keyboard for the duration of the onSubmit call.

onSubmit is expected to do whatever verification work is required (e.g. dispatching an action) and then signal one of three outcomes:

  • Returns true on success. The field is left as-is and the owner is expected to navigate away from the page to the next one.

  • Returns false on incorrect code. The widget shows an "Enter the correct code" error, then automatically clears the field and re-focuses so the user can try again.

  • Throws on verification failure (no internet, server error, …). The widget shows a "Could not verify the code" error and a "Retry" button below the digits, keeping the typed digits visible. Tapping "Retry" resubmits the same code via onSubmit again.

In all three failure cases the error clears automatically as soon as the user starts typing again.

Implementation

final Future<bool> Function(String code) onSubmit;