我正在使用此软件包:https://pub.dartlang.org/packages/flutter_typeahead。 我正在尝试使用BoxConstraints来限制建议的框宽大小,但这是行不通的。 这是我的代码:
return TypeAheadFormField(
textFieldConfiguration: TextFieldConfiguration(
controller: _typeAheadController,
decoration: InputDecoration(
prefixIcon: _icon,
hintText: _hintText),
),
suggestionsCallback: (String pattern) async {
return suggestions;
},
itemBuilder: (context, suggestion) {
if (suggestions.isNotEmpty)
ListTile(
title: Text(suggestion),
);
},suggestionsBoxDecoration: SuggestionsBoxDecoration(
constraints: BoxConstraints(maxWidth: 10, maxHeight: 10)
),
onSuggestionSelected: (suggestion) {
this._typeAheadController.text = suggestion;
},
hideOnEmpty: true,
);
对高度的约束有效,但对宽度的约束无效。