0

I am just wondering how should I go about making the Textfield widget to be on the center of the screen when the user taps on it?

Right now with what I have, the textfield gets the focus but it will be up only enough to barely be above the keyboard.

This is what I have:

class InputTextFields extends StatelessWidget {
  InputTextFields(
      {this.title,
      this.obscureText,
      this.setValue,
      this.keyboardType,
      this.inputTextFieldFocusNode});

  final String title;
  final bool obscureText;
  Function setValue;
  TextInputType keyboardType;
  FocusNode inputTextFieldFocusNode;
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(bottom: 10, left: 35, right: 35),
      child: TextField(
        //focusNode: focusNode,
        obscureText: obscureText,
        keyboardType: keyboardType,
        decoration: InputDecoration(
          labelText: title,
          labelStyle: TextStyle(
              fontFamily: 'Montserrat',
              fontWeight: FontWeight.bold,
              color: Colors.grey),
          focusedBorder: UnderlineInputBorder(
            borderSide: BorderSide(
              color: Colors.grey,
            ),
          ),
        ),
        onChanged: setValue,
        onTap: () {
          inputTextFieldFocusNode.requestFocus();
        },
      ),
    );
  }
}

They are being used in a SingleChildScrollView with a Column Widget as its children.

Thanks, I wish you a wonderful day

  • check [TextFormField hidden by keyboard](https://stackoverflow.com/questions/53586892/flutter-textformfield-hidden-by-keyboard) – Anas Oct 21 '20 at 03:46
  • @AnasMohammed Hey there! Thanks for your quick response. Yes I have tried that but it didn't work for me either. The focus is on the textfield but the location of the textfield is still just slightly above the keyboard, not on the center of the screen – SushiRiceOverEggs Oct 21 '20 at 04:56
  • can u add the picture of how its look like? – Anas Oct 21 '20 at 05:22

0 Answers0