Open dialog on tap in TextField before keyboard opens – Flutter

You can follow a simple trick. There is a read-only properties of TextField, you can use a flag on that read-only properties. When user chooses a selection from pop up, than change focus to that TextField.

bool readOnly = true;
FocusNode f1 = FocusNode();

TextFormField(                                
     read-only: readOnly ,
     focusNode: f1,
     decoration: InputDecoration(
     border: OutlineInputBorder(
     borderRadius: BorderRadius.circular(4.0)
      ),
      ),
     style: TextStyle(
      color: Colors.orange,
      fontSize: 15.0,
      ),
      ),

on your dialog code when selecting:

readOnly = false;
FocusScope.of(context).requestFocus(f1);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top