uiTabView method

Widget uiTabView({
  1. required List<CTabItem> tabItems,
  2. Key? key,
  3. bool automaticIndicatorColorAdjustment = true,
  4. Color? backgroundColor,
  5. Clip clipBehavior = Clip.hardEdge,
  6. double? height,
  7. EdgeInsetsGeometry? iconMargin,
  8. double indicatorWeight = 2.0,
  9. bool isScrollable = false,
  10. void onTap(
    1. int
    )?,
  11. TabBarTheme? style,
  12. double viewportFraction = 1.0,
})

Constructs a tab view of content to allow for users to switch between widgets of data.

Implementation

Widget uiTabView({
  required List<CTabItem> tabItems,
  Key? key,
  bool automaticIndicatorColorAdjustment = true,
  Color? backgroundColor,
  Clip clipBehavior = Clip.hardEdge,
  double? height,
  EdgeInsetsGeometry? iconMargin,
  double indicatorWeight = 2.0,
  bool isScrollable = false,
  void Function(int)? onTap,
  TabBarTheme? style,
  double viewportFraction = 1.0,
}) {
  // Parse the tabItems to construct the tab data.
  var tabs = <Widget>[];
  var contentList = <Widget>[];
  for (var w in tabItems) {
    tabs.add(
      Tab(
        key: key,
        icon: w.icon is IconData ? Icon(w.icon) : w.icon,
        iconMargin: iconMargin,
        height: height,
        text: w.title,
      ),
    );
    contentList.add(w.content);
  }

  // Go build the tabbed view based on that data and other configuration
  // items
  return DefaultTabController(
    length: tabItems.length,
    child: Scaffold(
      appBar: AppBar(
        backgroundColor: backgroundColor,
        toolbarHeight: height ?? 50.0,
        bottom: PreferredSize(
          preferredSize: Size.zero,
          child: SizedBox(
            height: height ?? 50.0,
            child: TabBar(
              automaticIndicatorColorAdjustment:
                  automaticIndicatorColorAdjustment,
              dividerColor: style?.dividerColor,
              dividerHeight: style?.dividerHeight,
              indicator: style?.indicator,
              indicatorColor: style?.indicatorColor,
              indicatorSize: style?.indicatorSize,
              indicatorWeight: indicatorWeight,
              labelColor: style?.labelColor,
              labelPadding: style?.labelPadding,
              labelStyle: style?.labelStyle,
              isScrollable: isScrollable,
              onTap: onTap,
              overlayColor: style?.overlayColor,
              padding: EdgeInsets.zero,
              tabAlignment: style?.tabAlignment,
              unselectedLabelColor: style?.unselectedLabelColor,
              unselectedLabelStyle: style?.unselectedLabelStyle,
              tabs: tabs,
            ),
          ),
        ),
      ),
      body: TabBarView(
        clipBehavior: clipBehavior,
        viewportFraction: viewportFraction,
        children: contentList,
      ),
    ),
  );
}