AutoCompleteTextField右对齐文本

时间:2019-09-26 09:49:53

标签: flutter flutter-layout flutter-dependencies

我使用了此程序包,以使用此代码创建一个自动完成的文本字段

       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);
                      },
                    )

它工作正常,但我需要使文本正确对齐并且不知道该如何做,任何人都可以帮助您?

1 个答案:

答案 0 :(得分:1)

AutoCompleteTextField小部件中包装Directionality

  Directionality( // add this
        textDirection: TextDirection.rtl, // set this property 
        child: AutoCompleteTextField(),
    )