gpt4 book ai didi

flutter - 水平滑动标签栏

转载 作者:行者123 更新时间:2023-12-03 03:39:44 30 4
gpt4 key购买 nike

我的 flutter 应用程序代码中有类似的东西,我无法在选项卡中水平滑动,你能帮我看看我哪里出错了吗。

getBody(var data) {
double maxHeight = MediaQuery.of(context).size.height;
developer.log('Max height:' + maxHeight.toString());
return Column(
children: <Widget>[
Container(
child: TabBar(
labelColor: Colors.black,
tabs: [
new Tab(text: 'Credit', icon: new Icon(Icons.list)),
new Tab(text: 'Debit', icon: new Icon(Icons.pie_chart)),
new Tab(text: 'Online', icon: new Icon(Icons.insert_chart)),
],
controller: _tabController,
onTap: _handleTabSelection,
),
),
Container(
margin: new EdgeInsets.all(0.0),
height: maxHeight - 229,
child: new Center(
child: new RefreshIndicator(
onRefresh: refreshList,
child: createReportList(context, data),
),
),
),
],
);
}

代码的输出是, The result of the above code, I have to click on each tab, sliding is not coming

最佳答案

请试试这个。

@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 6,
child: Scaffold(
appBar: AppBar(
centerTitle: true,
leading: Icon(Icons.person_outline),
title: Text("HOME SCREEN",style: TextStyle(fontSize: 16.0),),
bottom: PreferredSize(
child: TabBar(
isScrollable: true,
unselectedLabelColor: Colors.white.withOpacity(0.3),
indicatorColor: Colors.white,
tabs: [
Tab(
child: Text("Kumar"),
),
Tab(
child: Text("Lokesh"),
),
Tab(
child: Text("Rathod"),
),
Tab(
child: Text("Raj"),
),
Tab(
child: Text("Madan"),
),
Tab(
child: Text("Manju"),
)
]),
preferredSize: Size.fromHeight(30.0)),
actions: <Widget>[
Padding(
padding: const EdgeInsets.only(right: 16.0),
child: Icon(Icons.add_alert),
),
],
),
body: TabBarView(
children: <Widget>[
Container(
child: Center(
child: Text("Tab 1"),
),
),
Container(
child: Center(
child: Text("Tab 2"),
),
),
Container(
child: Center(
child: Text("Tab 3"),
),
),
Container(
child: Center(
child: Text("Tab 4"),
),
),
Container(
child: Center(
child: Text("Tab 5"),
),
),
Container(
child: Center(
child: Text("Tab 6"),
),
),
],
)),
);
}

关于flutter - 水平滑动标签栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57985911/

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