Flutter TextField自动完成覆盖 [英] Flutter TextField autocomplete overlay
问题描述
我正在努力创建具有自动完成覆盖的TextField。
我有一个带有TextFields的表单,我想根据在TextField中键入的内容显示建议。
I am struggling to create TextField with autocomplete overlay. I have form with TextFields and I want to display suggestions based on what is typed in TextField.
类似这样的事情:
文本字段自动完成
我不确定窗口小部件的层次结构应该如何实现以显示建议框在其他小部件上方。我应该使用Stack小部件,OverflowBox小部件还是其他?
Something like this: TextField autocomplete I am not sure what the hierarchy of widgets should look like to achieve displaying the suggestions box above other widgets. Should I use Stack widget, OverflowBox widget or something else?
赞赏按层次结构示例提供的任何帮助。
Any help by hierarchy example appreciated.
推荐答案
我已经实现了打包, flutter_typeahead 即可做到这一点。在此程序包中,我使用 Overlay.of(context).insert ,这使我可以在叠加层中插入建议列表,使其浮于所有其他小部件之上。我还写了这篇文章详细说明如何执行此操作
I have implemented a package, flutter_typeahead to do exactly that. In this package, I use Overlay.of(context).insert, which allows me to insert the suggestions list in the Overlay, making it float on top of all other widgets. I also wrote this article to explain how to do this in detail
这篇关于Flutter TextField自动完成覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!