首页 > 解决方案 > 在 Flutter 中使用扩展和灵活的小部件时移除额外空间

问题描述

想删除这个多余的空间在一个页面中包含两个部分。第二个是可滚动部分。页面顶部的第一个,不可滚动。但该部分包含一个 Textformfield。所以当 Keyboard 出现时,如果 Page Height 很短,它会显示“A RenderFlex 在底部溢出了 62 个像素”。所以第一部分用灵活的小部件包装。现在一个额外的空间出现在页面的底部。我怎样才能删除这个。?

Widget build(BuildContext context) {
    return Scaffold(resizeToAvoidBottomInset: true,extendBodyBehindAppBar: false,extendBody: false,
        appBar:AppBar(title: Text('AppBar'),backgroundColor: Colors.orange,elevation: 0.0,),
        body:SafeArea( child:Column(children: [
          //ClipRect(child:
      Flexible(child:
      Container(color:Colors.yellow,child:  ListView(shrinkWrap:true,children: [
            Center(child:Text('Do not Scroll this section',style: TextStyle(color: Colors.red),)),
            Column(children: [  Row(children: [
              Flexible(flex:1,fit:FlexFit.tight,child:Container(child:Text('name')),),Flexible(flex:1,fit:FlexFit.tight,child:Container(height:66,child:TextFormField(decoration:InputDecoration()))),]),])
          ]))),

          Expanded(child: ListView.builder(itemCount:450,scrollDirection:Axis.vertical,shrinkWrap:true,controller:scrollcontroller, itemBuilder: (_, index){return Column(children:[Text('Scrollable')]);}))

        ]),));}

标签: flutterflutter-layoutexpandflexible-type

解决方案


推荐阅读