composeAttributes function

Attributes? composeAttributes(
  1. Attributes? base,
  2. Attributes? other, {
  3. dynamic keepNull = false,
})

Implementation

Attributes? composeAttributes(
  Attributes? base,
  Attributes? other, {
  keepNull = false,
}) {
  base ??= {};
  other ??= {};
  Attributes attributes = {
    ...base,
    ...other,
  };

  if (!keepNull) {
    attributes = Attributes.from(attributes)
      ..removeWhere((_, value) => value == null);
  }

  return attributes.isNotEmpty ? attributes : null;
}