TextFormField hidden by keyboard - Flutter

大城市里の小女人 提交于 2020-02-24 12:18:05

问题


When focussing on the TextFormField, the keyboard hides over the TextFormField. I am using SingleScrollview with the Column widget. Below I attached a screenshot with coding. Please guide me in fixing this issue.

Scaffold(
  resizeToAvoidBottomInset: false,
  resizeToAvoidBottomPadding: false,
  key: _scaffoldKey,
  body: SingleChildScrollView(
  child: Padding(
    padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
    child: new Column(
      children: <Widget>[
        _tabText(),
        isSignin ? _loginContainer() : _signUpContainer(),
      ],
    ),),),);


回答1:


You have to remove these properties of the Scaffold:

  resizeToAvoidBottomInset: false,
  resizeToAvoidBottomPadding: false,

If you remove them, resizeToAvoidBottomInset will be true by default.

resizeToAvoidBottomInset property:

...if there is an onscreen keyboard displayed above the scaffold, the body can be resized to avoid overlapping the keyboard, which prevents widgets inside the body from being obscured by the keyboard.




回答2:


Try SingleChildScrollView() widget after scaffold() widget. wrap all widgets with SingleChildScrollView() widget after Scaffold() widget.

Widget build(BuildContext context) {
return Scaffold( 
  body: SingleChildScrollView(
    child: Form(
      key: formKey,
      child: Column(
        children: <Widget>[
          Container(
            child: Stack(
              children: <Widget>[
                Container(



回答3:


//Add this line "resizeToAvoidBottomInset: true," to your Scaffold and put your main container in ScrollView.

    @override
    Widget build(BuildContext context) {
   return Scaffold(
   resizeToAvoidBottomInset: true,
   key: _scaffoldKey,
   backgroundColor: Colors.white,
   body: SingleChildScrollView(    
      child: Container()
    ),
   );
  }


来源:https://stackoverflow.com/questions/59694058/textformfield-hidden-by-keyboard-flutter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!