我有一个水平列表,如下面的视频所示:
此列表是此代码生成的每周索引:
Expanded(
child: PageView.builder(
controller: _pageController,
itemBuilder: (context, weekIndex) {
return ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: WeekDays.days.length,
itemBuilder: (BuildContext context, int index) {
DateTime now = DateTime.now();
int milliseconds = now.millisecondsSinceEpoch -
(now.weekday - 1) * 24 * 60 * 60 * 1000 +
weekIndex * 7 * 24 * 60 * 60 * 1000 +
index * 24 * 60 * 60 * 1000;
DateTime dayDateTime =
DateTime.fromMillisecondsSinceEpoch(milliseconds);
int monthIndex = dayDateTime.month - 1;
List months = [
'Gen',
'Feb',
'Mar',
'Apr',
'Mag',
'Giu',
'Lug',
'Ago',
'Set',
'Ott',
'Nov',
'Dic'
];
List weekdays = ['Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab', 'Dom'];
String month = months[monthIndex];
String day = dayDateTime.day.toString();
String weekday = weekdays[dayDateTime.weekday - 1];
String date = weekday + ' ' + day + ' ' + month;
return Container(
width: 100,
child: Column(
children: [
Card(
color: now.weekday == index + 1 && weekIndex == 0
? Colors.orange[900]
: Colors.orange,
child: Container(
height: 40,
child: Center(
child: Text(
date,
style: TextStyle(fontSize: 13, color: Colors.white),
),
),
),
),
],
),
);
},
);
},
),
)
在列表的每个元素下方,我需要构建一个可滚动的一天中小时列表,用户可以点击该列表来预订特定日期的特定时间。
如何在每个每周元素列表下方获得一个独立列表?