How can I set the current cursor to the end of text editing controller when callback on onChanged in Flutter

Viewed 89

I have a function to pass the variable to tab builder screen in order to show dialog when user have changed the text in the tab. When user input something, I handle it in onChange, I set the variable and call the function in it. It show dialog when i change tab as i need but when editing text the cursor move to the first index of text field and i must keep click on it again to continue edit everytime I put character in. This is the function to call

void firedA() {
    print("A click was triggered in the subcomponent");
    widget.callback(_continue);
  }

My TextFormField

TextFormField(
    keyboardType: TextInputType.number,
                            controller: TextEditingController(
                                text: _textOxygenController.text),
                            onChanged: (val) {
                              _textOxygenController.text = val;
                              reportDTO.oxygen = val;
                              if (_textOxygenController.text.length > 0) {
                                _continue = true;
                                firedA();
                              } else {
                                _continue = false;
                                firedA();
                              }
                            },
                            style:
                                TextStyle(fontSize: 14, color: Colors.black))
0 Answers
Related