gpt4 book ai didi

flutter - 如何使用我的整个应用程序在 TabBarView 中创建可滚动的内容?

转载 作者:行者123 更新时间:2023-12-05 07:18:38 35 4
gpt4 key购买 nike

我在 SingleChildScrollView 中创建了 TabBar。问题是我想用我的整个应用程序在 TabBarView 中创建可滚动的内容,而不是仅在 TabBarView 中滚动内容。我尝试了 ListView.Builder 和 NestedScrollView 但没有与我一起工作..有什么解决方案吗?

这是我的代码:

    class TwitterTabBare extends StatefulWidget {
@override
_TwitterTabBareState createState() => _TwitterTabBareState();
}

class _TwitterTabBareState extends State<TwitterTabBare>
with SingleTickerProviderStateMixin {
TabController _tabController;
@override
void initState() {
super.initState();
_tabController = TabController(length: 4, vsync: this);
}

@override
Widget build(BuildContext context) {
double screenHeight = MediaQuery.of(context).size.height;
return column(
children: <Widget>[
TabBar(
controller: _tabController,
labelColor: Colors.blue,
unselectedLabelColor: Colors.grey[700],
tabs: <Widget>[
Tab(
text: 'Tweets',
),
Tab(
text: 'Replies',
),
Tab(
text: 'Media',
),
Tab(
text: 'Tweets',
),
],
),
Container(
constraints: BoxConstraints.expand(height: 300),
child: TabBarView(
controller: _tabController,
children: <Widget>[
// CardPage(),
Column(
mainAxisSize: MainAxisSize.max,
children: <Widget>[
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),
Text('Tweets & replies'),

],
),
Text('Replies'),
Text('Media'),
Text('Likes'),
],
),
),
],
);
}
}

Demo

最佳答案

您提供的代码片段的问题是该列不可滚动并在给定布局上溢出。您可以在这里考虑使用 ListView 来创建可滚动的 Widget。这是一个有效的 sample我发布的使用 ListView 和 TabBarView 的内容。要处理滑动到其他选项卡,需要使用 NestedScrollView。

关于flutter - 如何使用我的整个应用程序在 TabBarView 中创建可滚动的内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58227418/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com