简体   繁体   中英

how to avoid keyboard when textfield focused in flutter

when i touch hello TextFormField() keyboard cover my red check button so, I have to scroll up to see whole shape of button.

在此处输入图像描述

在此处输入图像描述

is there a way to fix this problem?

Add resizeToAvoidBottomInset to Scaffold:

@override
Widget build(BuildContext context) {
  return Scaffold(
      resizeToAvoidBottomInset: false, // add here

or wrap Colum with SingleChildScrollView as below:

SingleChildScrollView(    // wrap in
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
    
              TextFieldsHere

            ],
          ),
        ),

You can create a FocusNode as: FocusNode focusNode; And after initializing it in initState method, you can use focusNode property of TextFormField to assign your created focusNode to that property

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM