'Flutter how to center Textfield on screen after the user taps on it?

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



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source