Flutter SingleChildScrollView 部分不滚动
Flutter SingleChildScrollView section doesn't scroll
我有这个简单的脚手架,其中有 3 个容器,我希望第一个容器保持固定,并且只对第二个容器及以后的容器进行滚动。但出于某种原因,使用下面的代码,我根本无法滚动,我得到 overflow by xxx pixels on the bottom
错误。
Scaffold(
body: Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context).padding.top,
),
child: Column(
children: [
Container(
height: 300,
width: 400,
color: Colors.black,
),
SingleChildScrollView(
child: Column(
children: [
Container(
width: ScreenUtil().setWidth(578),
height: ScreenUtil().setWidth(578),
color: Colors.red,
margin: EdgeInsets.all(30),
),
Container(
width: ScreenUtil().setWidth(578),
height: ScreenUtil().setWidth(578),
color: Colors.red,
),
],
),
),
],
),
),
);
用 SingleChildScrollView
包裹第一列工作正常(在代码下方),但这允许滚动整个页面,这不是我想要的。我错过了什么?
Scaffold(
body: Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context).padding.top,
),
child: SingleChildScrollView(
child: Column(
children: [
Container(
height: 300,
width: 400,
color: Colors.black,
),
Container(
width: ScreenUtil().setWidth(578),
height: ScreenUtil().setWidth(578),
color: Colors.red,
margin: EdgeInsets.all(30),
),
Container(
width: ScreenUtil().setWidth(578),
height: ScreenUtil().setWidth(578),
color: Colors.red,
),
],
),
),
),
);
将 SingleChildScrollView 包裹在容器中并设置其大小
我有这个简单的脚手架,其中有 3 个容器,我希望第一个容器保持固定,并且只对第二个容器及以后的容器进行滚动。但出于某种原因,使用下面的代码,我根本无法滚动,我得到 overflow by xxx pixels on the bottom
错误。
Scaffold(
body: Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context).padding.top,
),
child: Column(
children: [
Container(
height: 300,
width: 400,
color: Colors.black,
),
SingleChildScrollView(
child: Column(
children: [
Container(
width: ScreenUtil().setWidth(578),
height: ScreenUtil().setWidth(578),
color: Colors.red,
margin: EdgeInsets.all(30),
),
Container(
width: ScreenUtil().setWidth(578),
height: ScreenUtil().setWidth(578),
color: Colors.red,
),
],
),
),
],
),
),
);
用 SingleChildScrollView
包裹第一列工作正常(在代码下方),但这允许滚动整个页面,这不是我想要的。我错过了什么?
Scaffold(
body: Container(
margin: EdgeInsets.only(
top: MediaQuery.of(context).padding.top,
),
child: SingleChildScrollView(
child: Column(
children: [
Container(
height: 300,
width: 400,
color: Colors.black,
),
Container(
width: ScreenUtil().setWidth(578),
height: ScreenUtil().setWidth(578),
color: Colors.red,
margin: EdgeInsets.all(30),
),
Container(
width: ScreenUtil().setWidth(578),
height: ScreenUtil().setWidth(578),
color: Colors.red,
),
],
),
),
),
);
将 SingleChildScrollView 包裹在容器中并设置其大小