Bottom overflow by 30px

2019-01-28 07:29发布

问题:

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 please help me

 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,)
          ),


        ],
      ),
    );
  }
}

回答1:

There are two solutions to this problem.

  1. Add resizeToAvoidBottomPadding: false to your Scaffold

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