ConvexAppBar.badge constructor
ConvexAppBar.badge(
- Map<
int, dynamic> badge, { - Key? key,
- Color? badgeTextColor,
- Color? badgeColor,
- EdgeInsets? badgePadding,
- EdgeInsets? badgeMargin,
- double? badgeBorderRadius,
- 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,
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,
);
}