我想实现两个列表同时滚动的功能。我在列表中放入了两个不可滚动的列表,但是会出现错误。
我从一个列表中获得了补偿,而另一个提出了移至该补偿的想法,但是我找不到办法。
我希望您告诉我该怎么做或提出新的方法。 这个问题对我很重要。请告诉我如何。
Row(
children: [
Expanded(
child: SizedBox(
height: 200,
child: ListView(
// scrollDirection: Axis.horizontal,
children: [
Container(
height: 36,
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount:
_selectedTimeStartBtn ? 24 : 49,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Container(
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(
horizontal: 17, vertical: 7),
decoration: new BoxDecoration(
color: Color(0xfffff2f1),
border: Border.all(
color: Color(0xffffdddb),
),
borderRadius:
BorderRadius.circular(5),
),
child: Text(
(index ~/ 24 == 2)
? '24:00'
: (index % 24 < 10)
? '0${index % 24}:00'
: '${index % 24}:00',
textAlign: TextAlign.center,
style: TextStyle(
fontFamily: 'NotoSansKR',
color: Color(0xfff03127),
fontSize: 16,
fontWeight: FontWeight.w400,
fontStyle: FontStyle.normal,
),
),
);
},
),
),
Container(
height: 36,
child: ListView.builder(
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemCount:
_selectedTimeStartBtn ? 24 : 49,
scrollDirection: Axis.horizontal,
itemBuilder: (context, index) {
return Container(
margin: index == 0
? EdgeInsets.only(left: 50)
: null,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(
horizontal: 17, vertical: 7),
decoration: new BoxDecoration(
color: Colors.grey,
border: Border.all(
color: Colors.grey,
),
borderRadius:
BorderRadius.circular(5),
),
child: Text('DATA'),
);
},
),
),
],
),
),
),
],
),
答案 0 :(得分:0)
尝试一下: