How can flutter TextField input boxes prefix and suffix be displayed without getting focus?

How can flutter TextField input boxes prefix and suffix be displayed without getting focus?

How can flutter TextField input boxes prefix and suffix be displayed without getting focus?
I have a mobile phone verification code login page, the front of the mobile phone number is displayed +86 by default, and the verification code input box is displayed by default to get verification code? Both Prefix and Suffix must be focused to display, how can I achieve this?

Answer:

TextField(
  decoration: InputDecoration(
    prefixIcon: Padding(
      padding: EdgeInsets.all(0.0),
      child: Text('+86', style: TextStyle(color: Colors.grey)),
    ),
    suffixIcon: Padding(
      padding: EdgeInsets.all(0.0),
      child: FlatButton(
        onPressed: () {
          //The code to get the verification code
        },
        child: Text('Get a verification code', style: TextStyle(color: Colors.blue)),
      ),
    ),
  ),
)

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *