unFocus method
void
unFocus()
Dismisses the software keyboard and removes the focus from any active text field.
This is an essential utility for improving user experience when a form is submitted or a button is pressed.
Example:
ElevatedButton(
onPressed: () {
context.unFocus();
// ... proceed with logic after ensuring keyboard is gone
},
child: const Text('Done'),
)
Implementation
void unFocus() => FocusScope.of(this).unfocus();