User reported on iPhone iOS 18: 'still a bit lag and stuck' after
the _kickFocus removal (1ceb47f). Web research (flutter/flutter
keyboard performance issues) and code review of GestureDetector
hit-test semantics identified the remaining race.
Root cause:
The outer GestureDetector wrapping the connect form Column was
using HitTestBehavior.translucent. Translucent semantics dispatch
the pointer event to BOTH the GestureDetector AND any descendant
hit-test target. So when the user tapped a TextField, two things
fired simultaneously:
1. GestureDetector.onTap -> FocusScope.of(context).unfocus()
This drove the keyboard *down* via the platform TextInput.hide
side effect of clearing focus.
2. TextField's own TapGestureRecognizer -> EditableText.attach
This drove the keyboard *up* via TextInput.show.
The two CAAnimations on iOS 18 raced each other inside the same
UIKit transaction, producing:
* 500-1000 ms of visible 'thinking' before the keyboard appeared
(one full slide-down + one full slide-up).
* Occasional 'stuck' state where the keyboard never came back up
because UIResponder.becomeFirstResponder was called before
resignFirstResponder finished.
Fix: switch to HitTestBehavior.opaque. With opaque:
* The GestureDetector still receives hit-test results for its
entire bounds (so taps on empty padding between fields still
reach onTap).
* But the gesture arena routes a tap that lands on a TextField
to that TextField's recognizer ONLY \u2014 the outer
GestureDetector loses the arena and its onTap does not fire.
* Net: tapping a field is exactly equivalent to having no outer
GestureDetector at all (no race, no lag, no stuck). Tapping
empty space still dismisses the keyboard cleanly.
This is the canonical pattern that several Stack Overflow answers
and the GestureDetector dartdoc recommend for 'tap-outside-to-
dismiss-keyboard'. translucent is for cases where you want both
the outer and inner to react simultaneously (rare).
flutter build ios --release --no-codesign: 29.0 s, Runner.app
30.2 MB.
chanora_flutter
Chanora — cross-platform voice client for TeamSpeak-compatible servers.
Getting Started
This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
For help getting started with Flutter development, view the online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.