Flutter:FormBuilderDropdown 自动完成
Posted
技术标签:
【中文标题】Flutter:FormBuilderDropdown 自动完成【英文标题】:Flutter : FormBuilderDropdown autocomplete 【发布时间】:2020-09-22 09:25:26 【问题描述】:我想自动完成 FormBuilderDropdown
中的项目。当我写一封信时,项目列表会更改以显示包含该字母的项目。
FormBuilderDropdown(
attribute: 'field_city',
decoration: LikpechInputDecoration(_isLoading, 'Selectionnez une ville'),
items: _buildListCities(),
/*initialValue: DropdownMenuItem(
value: _selectedCity,
child: Text(_listCities[_selectedCity]['name']),
),*/
onChanged: (index)
setState(()
_selectedCity = index;
);
fetchAgences(index);
,
validators: [
FormBuilderValidators.required(errorText: '')
],
) : Center(child: CupertinoActivityIndicator()),
【问题讨论】:
请分享您迄今为止为减轻帮助所做的尝试 我添加了部分代码,请检查 【参考方案1】:使用打字头插件typehead flutter
import 'package:flutter_typeahead/flutter_typeahead.dart';
.
.
.
TypeAheadField(
textFieldConfiguration: TextFieldConfiguration(
autofocus: true,
style: DefaultTextStyle.of(context).style.copyWith(
fontStyle: FontStyle.italic
),
decoration: InputDecoration(
border: OutlineInputBorder()
)
),
suggestionsCallback: (pattern) async
return await BackendService.getSuggestions(pattern);
,
itemBuilder: (context, suggestion)
return ListTile(
leading: Icon(Icons.shopping_cart),
title: Text(suggestion['name']),
subtitle: Text('\$$suggestion['price']'),
);
,
onSuggestionSelected: (suggestion)
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ProductPage(product: suggestion)
));
,
)
.
.
.
【讨论】:
以上是关于Flutter:FormBuilderDropdown 自动完成的主要内容,如果未能解决你的问题,请参考以下文章
[Flutter] flutter项目一直卡在 Running Gradle task 'assembleDebug'...
flutter 日志输出,Flutter打印日志,flutter log,flutter 真机日志
Flutter开发 Flutter 包和插件 ( Flutter 包和插件简介 | 创建 Flutter 插件 | 创建 Dart 包 )
如何解决flutter gradle build error?C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 991