Bottom overflow by 30px
Asked Answered
H

11

45

I face a problem by wrapping TextField with new Expanded(). When try to search something in textfield its show me bottom overflow by 30px. Below is my code:

 Widget build(BuildContext context) {
    return new Scaffold(
        body:
      Column(
        children: <Widget>[
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              IconButton(icon: Icon(Icons.search), onPressed: () {
                setState(() {

                });
              }),
              new Flexible(
                child: new TextField(
                  onChanged: (String value) {
                    onchange(value);
                  },
                  maxLines: 1,
                  autocorrect: true,
//                  decoration: const InputDecoration(helperText: "Search"),
                  style: new TextStyle(fontSize: 10.0, color: Colors.black),
                ),
              ),
              _text != null ? IconButton(
                  icon: Icon(Icons.close), onPressed: (){
              }) : new Container(),

              IconButton(icon: Icon(Icons.bookmark_border), onPressed: () {}),
            ],
          ),
          new Expanded(
              child: FilstList(searchtext: _text,)
          ),


        ],
      ),
    );
  }
}
Hogfish answered 22/8, 2018 at 17:38 Comment(1)
Hello! You can use Single Child Scroll View to avoid pixel over flow.Thank YouZinkenite
P
99

There are two solutions to this problem.

resizeToAvoidBottomPadding is now deprecated.

Below property of scaffold will work now. resizeToAvoidBottomInset set to false in scaffold widget.

  1. Add resizeToAvoidBottomInset: false to your Scaffold

     Scaffold(
      resizeToAvoidBottomInset: false,
     body: ...)
    
  2. Put your FilstList(searchtext: _text,) inside a scrollableView (like SingleChildScrollView or ListView)

Pelaga answered 22/8, 2018 at 18:20 Comment(2)
resizeToAvoidBottomPadding is now deprecated. Use resizeToAvoidBottomInset: false instead.Knawel
This stopped the content of my body from being displayed. The body is a TabBarView. Each tab view has a dynamic height as it is populated with data from a server, so the views don't have a size available to them. Placing the TabBarView inside a fixed size Container reduces UI quality.Rife
T
13

Use Scaffold property "resizeToAvoidBottomPadding: false" and "SingleChildScrollView" as parent of Scaffold body:

      home: Scaffold(
          resizeToAvoidBottomPadding: false,
          appBar: AppBar(
            title: Text("Registration Page"),
          ),
          body: SingleChildScrollView(
            child: RegisterUser(),
          )),

this will solve issue.

Tragicomedy answered 9/8, 2019 at 11:0 Comment(1)
omg thank you! doinght both of this like you told me worked!Wallack
M
10

You should use resizeToAvoidBottomInset

Scaffold(
  resizeToAvoidBottomInset: false, // set it to false
  ... 
)

If you're having issues with overflow error, use SingleChildScrollView with it.

Scaffold(
  resizeToAvoidBottomInset: false, // set it to false
  body: SingleChildScrollView(child: YourBody()),
)
Mind answered 10/8, 2019 at 12:0 Comment(0)
B
4

put resizeToAvoidBottomPadding as false in Scaffold:

  Scaffold(
    resizeToAvoidBottomPadding: false, 

update it is better solution: remove Column and put instead it ListView

because if you run this app on smaller device bottom items will disappear and hide from the show screen and that will be bad for App users.

Burthen answered 23/6, 2019 at 7:15 Comment(0)
P
4

I faced a similar problem and fixed it in the following way:

You can wrap it with SingleChildScrollView or with a ListView.

Scaffold(
    body: Container(
      height: MediaQuery.of(context).size.height * .50,
      child: SingleChildScrollView(
          child: Column( 
              ....
          )
      )
   )
 );
Perithecium answered 31/7, 2020 at 9:38 Comment(0)
P
3

Use of resizeToAvoidBottomInset: false in your Scaffold is the best solution to that.

Phooey answered 25/7, 2021 at 22:19 Comment(0)
G
1

Do two way

NO1.

Scaffold(
 resizeToAvoidBottomPadding: false, )

The problem is when you do this body content never gone top when you select input box..

Best practice

SingleChildScrollView widget

Guinea answered 4/11, 2020 at 13:38 Comment(0)
C
0

Used SigleChildScrollView

sample code

Scaffold(
          appBar: //AppBar
          body: SingleChildScrollView(
            padding: EdgeInsets.symmetric(horizontal: 5.0, vertical: 3.0),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
Cloison answered 19/7, 2019 at 8:47 Comment(0)
F
0

Use CustomScrollView with SliverToBoxAdapter:

body: CustomScrollView( 
  slivers: [
     SliverToBoxAdapter(
         child: Form(....)
     ),
  ]
)
Farthermost answered 4/12, 2022 at 12:18 Comment(0)
G
0

Use Scaffold and make "resizeToAvoidBottomInset" false.

 Scaffold(
            resizeToAvoidBottomInset: false,
            ........
   )
Glutathione answered 30/1, 2023 at 15:4 Comment(1)
not working............Lidstone
A
0

Solution 1: Using SingleChildScrollView Wrap the body of your Scaffold with SingleChildScrollView. This will make the entire body scrollable and prevent overflow when the keyboard appears.

Scaffold(
  body: SingleChildScrollView(
    child: Column(
      children: <Widget>[
        // Your other widgets go here
      ],
    ),
  ),
);

Solution 2: Using resizeToAvoidBottomInset Set resizeToAvoidBottomInset to false in the Scaffold. This will prevent the layout from resizing when the keyboard appears.

Scaffold(
  resizeToAvoidBottomInset: false,
  body: Column(
    children: <Widget>[
      // Your other widgets go here
    ],
  ),
);
Author answered 25/6 at 9:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.