Flutter 控件超出异常:A RenderFlex overflowed by 48 pixels on the bottom.
![](https://img.haomeiwen.com/i1689895/b725770465b8a984.png)
解决方案
- 在创建 Scaffold 时添加 resizeToAvoidBottomInset 属性,缺点是软禁盘下面的控件就被挡住了。如下:
return Scaffold(
resizeToAvoidBottomInset: false, //添加这一行
appBar: AppBar(
title: Text('Expenses Tracker'),
),
body: Column(
children: <Widget>[
...... // other widgets
],
),
);
- 使用滚动布局 SingleChildScrollView 包裹控件即可。如下:
return Scaffold(
appBar: AppBar(
title: Text('Expenses Tracker'),
),
body: SingleChildScrollView( // wrap with a scrollable widget
child: Column(
children: <Widget>[
...... // other widgets
],
),
),
);
按需使用即可。
网友评论