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

@@ -277,6 +277,12 @@ class _ConnectionPageState extends State<ConnectionPage>
},
));
},
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;
@@ -304,7 +310,7 @@ class _ConnectionPageState extends State<ConnectionPage>
: Padding(
padding: const EdgeInsets.only(top: 5),
child: ListView(
children: options.map((peer) => AutocompletePeerTile(idController: _idController, peer: peer)).toList(),
children: options.map((peer) => AutocompletePeerTile(onSelect: () => onSelected(peer), peer: peer)).toList(),
),
),
),