TabbarViewPager constructor

TabbarViewPager({
  1. Key? key,
  2. required List<String> tabList,
  3. required Widget onPageBuilder(
    1. BuildContext context,
    2. int index
    ),
  4. Widget onTabBuilder(
    1. BuildContext context,
    2. int index,
    3. String title
    )?,
  5. Color tabbarBackground = Colors.white,
  6. double tabbarWidth = double.infinity,
  7. bool tabbarIsScrollable = true,
  8. bool preNextPage = false,
  9. Color tabbarIndicatorColor = Colors.blue,
  10. Color dividerColor = Colors.transparent,
  11. TabBarIndicatorSize tabbarIndicatorSize = TabBarIndicatorSize.label,
  12. TextStyle tabbarLabelStyle = const TextStyle(color: Colors.black, fontSize: 16, fontWeight: FontWeight.bold),
  13. TextStyle tabbarUnselectedLabelStyle = const TextStyle(color: ColorConfig.black_5c5c5c, fontSize: 16, fontWeight: FontWeight.normal),
  14. bool canUserScroll = true,
  15. ValueChanged<int>? onPageChanged,
  16. ScrollPhysics? physics,
  17. 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);