TabbarViewPager constructor
TabbarViewPager({
- Key? key,
- required List<
String> tabList, - required Widget onPageBuilder(
- BuildContext context,
- int index
- Widget onTabBuilder(
- BuildContext context,
- int index,
- String title
- Color tabbarBackground = Colors.white,
- double tabbarWidth = double.infinity,
- bool tabbarIsScrollable = true,
- bool preNextPage = false,
- Color tabbarIndicatorColor = Colors.blue,
- Color dividerColor = Colors.transparent,
- TabBarIndicatorSize tabbarIndicatorSize = TabBarIndicatorSize.label,
- TextStyle tabbarLabelStyle = const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold),
- TextStyle tabbarUnselectedLabelStyle = const TextStyle(color: ColorConfig.black_5c5c5c, fontSize: 16, fontWeight: FontWeight.normal),
- bool canUserScroll = true,
- ValueChanged<
int> ? onPageChanged, - ScrollPhysics? physics,
- PageController? pageController,
快速构建TabBar+ViewPager的组合控件
tabList 标题Tab列表
onPageBuilder page子视图构建器
onTabBuilder tab子视图构建器,为空则使用默认的tab视图
tabbarBackground tabbar的背景颜色,默认白色
tabbarWidth tabbarWidth宽度,默认撑满父容器
tabbarIsScrollable tabbar是否可以滑动,默认可以
preNextPage 是否需要预加载上一页和下一页,默认false
tabbarIndicatorColor tabbar指示器(下面的横线)颜色,默认是蓝色
dividerColor 分割线颜色,默认是透明色
tabbarIndicatorSize tabbar指示器(下面的横线)大小模式,默认是TabBarIndicatorSize.label
tabbarLabelStyle tabbar选中tab的文字样式
tabbarUnselectedLabelStyle tabbar未选中tab的文字样式
canUserScroll 用户是否可以手动滑动page进行page切换
onPageChanged 页面切换监听
pageController 页面切换控制器
Implementation
TabbarViewPager({
super.key,
required this.tabList,
required this.onPageBuilder,
this.onTabBuilder,
this.tabbarBackground = Colors.white,
this.tabbarWidth = double.infinity,
this.tabbarIsScrollable = true,
this.preNextPage = false,
this.tabbarIndicatorColor = Colors.blue,
this.dividerColor = Colors.transparent,
this.tabbarIndicatorSize = TabBarIndicatorSize.label,
this.tabbarLabelStyle = const TextStyle(
color: Colors.black,
fontSize: 16,
fontWeight: FontWeight.bold,
),
this.tabbarUnselectedLabelStyle = const TextStyle(
color: ColorConfig.black_5c5c5c,
fontSize: 16,
fontWeight: FontWeight.normal,
),
this.canUserScroll = true,
this.onPageChanged,
this.physics,
PageController? pageController,
}) : pageController =
pageController ?? PageController(initialPage: 0, keepPage: true);