Flutter 基于内容的列表视图生成器大小
我有一个选项卡栏,每个选项卡都有不同数量的列表 这是密码Flutter 基于内容的列表视图生成器大小,flutter,dart,Flutter,Dart,我有一个选项卡栏,每个选项卡都有不同数量的列表 这是密码 Column( children: [ TabBar( controller: _tabController, unselectedLabelColor: Colors.black54, indicatorSize: TabBarIndicatorSize.tab, i
Column(
children: [
TabBar(
controller: _tabController,
unselectedLabelColor: Colors.black54,
indicatorSize: TabBarIndicatorSize.tab,
indicator: new BubbleTabIndicator(
indicatorHeight: 25.0,
indicatorColor: Colors.blueAccent,
tabBarIndicatorSize: TabBarIndicatorSize.tab,
),
tabs: [
Tab(text: 'one'),
Tab(text: 'two'),
],
),
Container(
height: 200.0,
child: TabBarView(controller: _tabController, children: [
ListView.builder(
padding: EdgeInsets.all(0),
itemCount: 10,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) =>
Center(child: Text('${index + 1}')),
),
ListView.builder(
padding: EdgeInsets.all(0),
itemCount: 20,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (BuildContext context, int index) =>
Center(child: Text('${index + 1}')),
),
]),
),
],
),
截图:
在第二幅图中,我无法向下滚动,因为我给了它一个高度
顺便说一下,我使用了CustomScrollView,它有一个SliverPersistentHeader
我需要的是删除容器的高度,让身体的大小是基于内容
谢谢。您无法滚动,因为您正在使用
物理:NeverScrollableScrollPhysics()
。如果删除,则它将滚动。然后您还可以卸下容器
要使用CustomScrollView
将正文扩展到内容大小,use应将ListView
s切换到SliverList
s,但这意味着您需要删除列
和TabBarView
小部件。因此,请尝试我的第一个建议,从您的ListView中删除物理
,并希望它能起作用
如果由于滚动发光而添加了NeverScrollableScrollPhysics
,那么我有一个程序包,名为