当前位置:网站首页>Flutter TabBarView组件
Flutter TabBarView组件
2022-06-21 18:52:00 【xiangxiongfly915】
Flutter TabBarView组件
简述
TabBarView 是 Material 组件库中提供了 Tab 布局组件,通常和 TabBar 配合使用。
TabBarView封装了PageView,使用起来非常简单。
基本属性
TabBarView
controller:TabBarView控制器。
children:子元素。
TabBar
tabs 一系列标签控件
controller 标签选择变化控制器
isScrollable 是否可滚动,默认false
indicatorColor 指示器颜色
indicatorWeight 指示器粗细
indicator 指示器,可自定义形状等样式
indicatorSize 指示器长短,tab:和tab一样长,label:和标签label 一样长
labelColor 标签颜色
labelStyle 标签样式
labelPadding 标签padding
unselectedLabelColor 未选中标签颜色
unselectedLabelStyle 未选中标签样式
简单使用

class TabBarViewPage extends StatefulWidget {
const TabBarViewPage({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() {
return _TabBarViewPageState();
}
}
class _TabBarViewPageState extends State<TabBarViewPage> with SingleTickerProviderStateMixin {
final List tabs = ["One", "Two", "Three", "Four", "Five", "Six", "Seven"];
late TabController _controller;
@override
void initState() {
_controller = TabController(length: tabs.length, vsync: this);
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("TabBarView & PageView"),
bottom: TabBar(
indicatorColor: Colors.red,
controller: _controller,
isScrollable: true,
tabs: tabs.map((e) {
return Tab(text: e);
}).toList(),
),
),
body: TabBarView(
dragStartBehavior: DragStartBehavior.down,
controller: _controller,
children: tabs.map((e) {
return Container(
alignment: Alignment.center,
child: Text(e, textScaleFactor: 3),
);
}).toList(),
),
);
}
}
边栏推荐
猜你喜欢

Zabbix6.0+timescaledb+ enterprise wechat alarm

瀚高数据库自定义操作符'!~~'

mysql如何對列求和

FS9935 高效率恒流限流 WLED 驱动IC

Comment MySQL additionne les colonnes

某大厂第二轮裁员来袭,套路满满

mysql如何查询最大id值

高等代数_第9章:线性映射

Selected articles of the research paper | interpretation of the trend of McKinsey's China's Digital Innovation future

Details, MySQL_ DATE_ FORMAT()_ Functions_ Detailed explanation (remember to collect)
随机推荐
Comment MySQL additionne les colonnes
大鱼吃小鱼小游戏完整版
什么比国内现货白银更有优势?
Big fish eat small fish games full version
TC3608H高效率 1.2MHz DC-DC 升压器 IC
Details, MySQL_ DATE_ FORMAT()_ Functions_ Detailed explanation (remember to collect)
Category
How to distinguish between machine learning and pattern recognition?
国标设备注册EasyCVR平台,如何修改设备在离线状态判断的时间?
深度学习图像数据增强
SQL教程之数据科学家需要掌握的五种 SQL 技能
Which platform is the best and safest for retail investors to buy funds
传iPhone 14将全系涨价;TikTok美国用户数据转移到甲骨文,字节无法访问;SeaTunnel 2.1.2发布|极客头条
QX2308高效 PFM 同步升压 DC/DC 变换器
How to use memcached to implement Django project caching
Simple integration of client go gin IX create
Delete the penultimate node - linked list topic
client-go gin的简单整合九-Create
Advanced algebra_ Chapter 9: linear mapping
服务器正文17:内存映射和共享内存的简单理解