fix, autocomplete, fill id field

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-10-27 17:00:13 +08:00
parent 8cc9e30f86
commit e32748daf2
3 changed files with 17 additions and 10 deletions

View File

@@ -245,6 +245,12 @@ class _ConnectionPageState extends State<ConnectionPage> {
inputFormatters: [IDTextInputFormatter()],
);
},
onSelected: (option) {
setState(() {
_idController.id = option.id;
FocusScope.of(context).unfocus();
});
},
optionsViewBuilder: (BuildContext context, AutocompleteOnSelected<Peer> onSelected, Iterable<Peer> options) {
double maxHeight = options.length * 50;
maxHeight = maxHeight > 200 ? 200 : maxHeight;
@@ -268,7 +274,7 @@ class _ConnectionPageState extends State<ConnectionPage> {
)))
: ListView(
padding: EdgeInsets.only(top: 5),
children: options.map((peer) => AutocompletePeerTile(idController: _idController, peer: peer)).toList(),
children: options.map((peer) => AutocompletePeerTile(onSelect: () => onSelected(peer), peer: peer)).toList(),
))))
);
},