Commit 28a4968
authored
fix(keyboard): improve keyboard hiding logic with focus check
Refactored _hideKeyboard method to use FocusScope.of(context).unfocus() only when there's an active focus that is not the primary focus. This is more precise than calling requestFocus(FocusNode()), which can cause issues like:
Attaching a focus node without context may throw runtime exceptions.
It introduces unnecessary focus traversal, which may lead to unexpected behavior in complex focus trees.
unfocus() is a cleaner, Flutter-recommended way to dismiss the keyboard.
This approach safely checks focus state and dismisses the keyboard only when appropriate, avoiding crashes and unwanted side effects.1 parent e88925e commit 28a4968
1 file changed
+4
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
353 | 353 | | |
354 | 354 | | |
355 | 355 | | |
356 | | - | |
357 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
358 | 360 | | |
359 | | - | |
360 | 361 | | |
361 | 362 | | |
362 | 363 | | |
| |||
0 commit comments