overlay_container
overlay_container copied to clipboard
TextField inside Overlay
Adding TextField and when focusing rebuilds the overlay and looses focus. Any idea how to fix this?
Hi @igala!
Thanks for raising this issue. If I had to suggest something right now I would suggest this fix. Steps to follow: • Fork this repo.
• Inside the file https://github.com/MustansirZia/overlay_container/blob/master/lib/overlay_container.dart change the _show
method to this.
void _show() {
WidgetsBinding.instance.addPostFrameCallback((_) async {
await Future.delayed(Duration(milliseconds: 280));
if (_overlayEntry == null) {
_overlayEntry = _buildOverlayEntry();
Overlay.of(context).insert(_overlayEntry);
} else {
_overlayEntry.markNeedsBuild();
}
_opened = true;
});
}
and the _hide
method to this.
void _hide() {
if (_opened) {
WidgetsBinding.instance.addPostFrameCallback((_) {
_overlayEntry.remove();
_overlayEntry = null;
_opened = false;
});
}
}
• Install the fork instead of the original library as shown for this example.

This will in turn not rebuild the overlay from scratch like the way it's doing right now. Let me know how it goes! :)