我只希望表日历的标题按月显示结果,这就是为什么将日历重叠到标题与另一列,其中显示数据列表,一切正常,但我无法滚动到列表的末尾,我正在尝试很多事情但失败了请帮我解决这个问题
这是我的代码示例
body: SingleChildScrollView(
scrollDirection: Axis.vertical,
physics: const AlwaysScrollableScrollPhysics(),
child: Container(
child: Stack(
clipBehavior: Clip.none,
children: [
SizedBox(
width: 430,
child: TableCalendar(
headerVisible: true,
),
),
Positioned(
top: 66.0,
child: Container(
width: MediaQuery.of(context).size.width,
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height,
),
child: Column(
children: [
Container(
height: 45,
width: 430,
child: Row(
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 20),
child: Column(children: [
for (var i = 0; i < _events.length; i++) ...[
ListTile(....
),
]
])),
),
],
),
),
),
],
),
),
),
如果我正确理解您的问题,我可以建议以下选项作为您实施的一部分:
SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: <Widget>[
SizedBox(
width: 430,
child: TableCalendar(
headerVisible: true,
),
),
Container(
width: MediaQuery.of(context).size.width,
child: Column(
children: <Widget>[
Container(
height: 45,
width: 430,
child: Row(
// Add your Row configuration here if necessary
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0, bottom: 20),
child: Column(
children: <Widget>[
// You can change this loop to
// for (Event event in _events) ...{
// ListTile(title: Text(even.name)),
// },
for (var i = 0; i < _events.length; i++) ...{
ListTile(title: Text('Title')),
}
],
),
),
],
),
),
],
),
)
主要问题是 SingleChildScrollView 不会自动计算其子级位于 Stack 中时的总高度。这可能会导致可滚动区域不够大,无法包含所有内容,尤其是在使用将其子级带出正常文档流的定位小部件时。