merge static method
Widget
merge({
- required bool last,
- required Widget child,
- FVariants<
FItemVariantConstraint, FItemVariant, FItemStyle, FItemStyleDelta> ? styles, - double? spacing,
- FItemDivider? divider,
- FVariants<
FItemGroupVariantConstraint, FItemGroupVariant, Color, Delta> ? dividerColor, - double? dividerWidth,
- bool? enabled,
- bool? intrinsicWidth,
- int? index,
Creates a FInheritedItemData that merges the given fields with the current FInheritedItemData.
Implementation
static Widget merge({
required bool last,
required Widget child,
FVariants<FItemVariantConstraint, FItemVariant, FItemStyle, FItemStyleDelta>? styles,
double? spacing,
FItemDivider? divider,
FVariants<FItemGroupVariantConstraint, FItemGroupVariant, Color, Delta>? dividerColor,
double? dividerWidth,
bool? enabled,
bool? intrinsicWidth,
int? index,
}) => Builder(
builder: (context) {
final parent = maybeOf(context);
final globalLast = last && (parent?.globalLast ?? true);
return FInheritedItemData(
data: FItemData(
styles: styles ?? parent?.styles,
spacing: max(spacing ?? 0, parent?.spacing ?? 0),
dividerColor: dividerColor ?? parent?.dividerColor ?? const .all(Colors.transparent),
dividerWidth: dividerWidth ?? parent?.dividerWidth ?? 0,
divider: switch ((last, globalLast)) {
// The first/middle items of a group.
(false, false) => divider ?? .none,
// Last of a group which itself isn't the last.
// propagatedLast can only be false if parent?.last is false since last must always be true.
// Hence, parent!.divider can never be null.
(true, false) => parent!.divider,
// The last item in the last group.
(_, true) => .none,
},
enabled: enabled ?? parent?.enabled ?? true,
intrinsicWidth: intrinsicWidth ?? parent?.intrinsicWidth ?? false,
index: index ?? parent?.index ?? 0,
last: last,
globalLast: globalLast,
),
child: child,
);
},
);