Flutter -TextField Controller gets the cursor before Text

dart, flutter, flutter-dependencies, flutter-layout, material-design

I get this warnings on my Console

W/IInputConnectionWrapper(25185): getTextBeforeCursor on inactive InputConnection
W/IInputConnectionWrapper(25185): getSelectedText on inactive InputConnection
W/IInputConnectionWrapper(25185): getTextAfterCursor on inactive InputConnection

I am using dateTime keyboard, when I enter text in textfield the cursor moves before the Text. This is annoying. I read somewhere that the TextEditing controller needs to be disposed/ closed. I am not sure how and what does that mean. Any one knows how to do away with these warnings and weird behavior on the TextInputController.

Best Solution

i have same problem, My Taski want to clear my textfield on button click

here is my code

String searchData = ""; TextEditingController searchEditor = TextEditingController();            Row(                children: <Widget>[                  Expanded(                    child: TextField(  // My textbox                      controller: searchEditor,                      autofocus: false,                      onChanged: (str){                        searchData = (str == null)? "" : str;                        setState(() {                        });                      },                      decoration: InputDecoration(                        prefixIcon: IconTheme(                          child: Icon(Icons.search),                          data: IconThemeData(color: Colors.blueAccent),                        ),                        labelText: 'Search',                      ),                    ),                    flex: 8,                  ),                  Expanded(                    child: RaisedButton(                      color: Basic.hbColor,                      textColor: Colors.white,                      child: Icon(Icons.clear),                      onPressed: (){      // On button click                        FocusScope.of(context).unfocus();   // Close keyboard                        setState(() {                          searchData = "";                        });                        Future.delayed(Duration(microseconds: 500),(){   //call back after 500  microseconds                          searchEditor.clear();  // clear textfield                         });                      },                      elevation: 10,                    ),                    flex: 2,                  )                ],              )

i solved by USING 'searchEditor.clear();' inside Future.delayedBecause when we call FocusScope.of(context).unfocus(); for closing keyboard it take some microseconds for close that's why it show this WANRING i.e. getTextBeforeCursor on inactive InputConnectionto overcome i called searchEditor.clear(); method after some microseconds

it's work for me.