我使用此程序包使用此代码来具有自动完成的文本字段
AutoCompleteTextField<Item>(
key: key,
clearOnSubmit: false,
suggestions: items,
style: TextStyle(color: Colors.blue, fontSize: 16.0),
decoration: InputDecoration(
contentPadding:
EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
hintText: "المنتج",
border: InputBorder.none,
hintStyle:
TextStyle(color: Colors.blue, fontSize: 16.0),
),
itemFilter: (s, query) {
// print(query.toLowerCase());
return s.Name.toLowerCase()
.startsWith(query.toLowerCase());
},
itemSorter: (a, b) {
return a.Name.compareTo(b.Name);
},
itemSubmitted: (s) {
String n = s.Name;
String p = s.Price.toString();
setState(() {
searchAutoCompleteTextField
.textField.controller.text = n;
txt.text = p;
});
},
itemBuilder: (context, item) {
return row(item);
},
)
并且它工作正常,但我需要使文本正确对齐,并且不知道该如何做,任何人都可以帮助您?
将您的AutoCompleteTextField
包装在Directionality
小部件中
Directionality( // add this
textDirection: TextDirection.rtl, // set this property
child: AutoCompleteTextField(),
)