3

i used this this package to have an autocomplete text field with this code

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

and it works fine but i need to have the text in the right alignment and don't know how to do this anyone could help??

3
  • have you try to wrap your Directionality( // add this textDirection: TextDirection.rtl, // set this property child: AutoCompleteTextField(), ) Sep 26, 2019 at 9:58
  • 1
    it works fine add this as answer so i can vote it
    – dev radwa
    Sep 26, 2019 at 10:26
  • okay, thanks added answer Sep 26, 2019 at 10:39

1 Answer 1

1

Wrap your AutoCompleteTextField inside Directionality widget

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.