ConvexAppBar.badge constructor

ConvexAppBar.badge(
  1. Map<int, dynamic> badge, {
  2. Key? key,
  3. Color? badgeTextColor,
  4. Color? badgeColor,
  5. EdgeInsets? badgePadding,
  6. EdgeInsets? badgeMargin,
  7. double? badgeBorderRadius,
  8. required List<TabItem> items,
  9. int? initialActiveIndex,
  10. bool? disableDefaultTabController,
  11. GestureTapIndexCallback? onTap,
  12. TapNotifier? onTabNotify,
  13. TabController? controller,
  14. Color? color,
  15. Color? activeColor,
  16. Color? backgroundColor,
  17. Color? shadowColor,
  18. Gradient? gradient,
  19. double? height,
  20. double? curveSize,
  21. double? top,
  22. double? elevation,
  23. double? cornerRadius,
  24. TabStyle? style,
  25. Curve? curve,
})

Construct a new appbar with badge.

badge is map with tab items, the value of entry can be either String, IconData, Color or Widget.

ConvexAppBar.badge(
  {3: '99+'},
  items: [
    TabItem(title: 'Tab A', icon: Icons.add),
    TabItem(title: 'Tab B', icon: Icons.near_me),
    TabItem(title: 'Tab C', icon: Icons.web),
  ],
)

Implementation

factory ConvexAppBar.badge(
  Map<int, dynamic> badge, {
  Key? key,
  // config for badge
  Color? badgeTextColor,
  Color? badgeColor,
  EdgeInsets? badgePadding,
  EdgeInsets? badgeMargin,
  double? badgeBorderRadius,
  // parameter for appbar
  required List<TabItem> items,
  int? initialActiveIndex,
  bool? disableDefaultTabController,
  GestureTapIndexCallback? onTap,
  TapNotifier? onTabNotify,
  TabController? controller,
  Color? color,
  Color? activeColor,
  Color? backgroundColor,
  Color? shadowColor,
  Gradient? gradient,
  double? height,
  double? curveSize,
  double? top,
  double? elevation,
  double? cornerRadius,
  TabStyle? style,
  Curve? curve,
}) {
  DefaultChipBuilder? chipBuilder;
  if (badge.isNotEmpty) {
    chipBuilder = DefaultChipBuilder(
      badge,
      textColor: badgeTextColor ?? Colors.white,
      badgeColor: badgeColor ?? Colors.redAccent,
      padding: badgePadding ?? EdgeInsets.only(left: 4, right: 4),
      margin: badgeMargin ?? EdgeInsets.only(top: 10, right: 10),
      borderRadius: badgeBorderRadius ?? 20,
    );
  }
  return ConvexAppBar(
    key: key,
    items: items,
    initialActiveIndex: initialActiveIndex,
    disableDefaultTabController: disableDefaultTabController ?? false,
    onTap: onTap,
    onTabNotify: onTabNotify,
    controller: controller,
    color: color,
    activeColor: activeColor,
    backgroundColor: backgroundColor,
    shadowColor: shadowColor,
    gradient: gradient,
    height: height,
    curveSize: curveSize,
    top: top,
    elevation: elevation,
    cornerRadius: cornerRadius,
    style: style,
    curve: curve,
    chipBuilder: chipBuilder,
  );
}