如何在tabBarView中添加两个列表,并且不干扰彼此的行为。
我将两个listView放在一列中,水平方向一个取1/5,另一个取4/5。问题是,当我滚动其中一个listView时,另一个也滚动了。
class ShopDetailPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
child: Scaffold(
body: NestedScrollView(
headerSliverBuilder:
(BuildContext context, bool innerBoxIsScrolled) {
return <Widget>[
SliverAppBar(
iconTheme: IconThemeData(color: Colors.black),
expandedHeight: 250.0,
floating: false,
pinned: true,
backgroundColor: Colors.white,
elevation: 0,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text("",
style: TextStyle(
color: Colors.black,
fontSize: 16.0,
)),
background: _ShopTitle(shopDetail: shopDetail)),
bottom: TabBar(
labelColor: Color(0xff333333),
unselectedLabelColor: Color(0xff333333),
tabs: [
Tab(
text: "商品",
),
Tab(
text: "商家",
),
Tab(
text: "活动",
)
]),
),
];
},
body: TabBarView(children: <Widget>[
Row(
children: <Widget>[
Container(
width: window.physicalSize.width /
3 /
window.devicePixelRatio,
child: ListView(
children: <Widget>[
for (int i = 0; i < 30; i++)
_CategoryDataItem(
category: new Category((c) => c
..name = "热销专区"
..id = "1"
..shopId = "1")),
],
),
),
Container(
width: window.physicalSize.width /
3 /
window.devicePixelRatio *
2,
child: ListView.separated(
itemBuilder: (context, index) => _ProductDataItem(),
separatorBuilder: (context, index) => Divider(
color: Colors.white,
),
itemCount: 30)),
],
),
_ShopIntroduce(
shopDetail: shopDetail,
),
Text('3'),
])),
));
}
}
如何控制listView,使其不受其他listView的干扰。