AutoCompleteTextField右对齐

问题描述 投票:1回答:1

我使用此程序包使用此代码来具有自动完成的文本字段

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

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

flutter flutter-layout flutter-dependencies
1个回答
0
投票

将您的AutoCompleteTextField包装在Directionality小部件中

  Directionality( // add this
        textDirection: TextDirection.rtl, // set this property 
        child: AutoCompleteTextField(),
    )
© www.soinside.com 2019 - 2024. All rights reserved.