mapIf method

Printer<T> mapIf(
  1. bool condition,
  2. Printer<T> callback(
    1. Printer<T> printer
    )
)

Helper to modify a printer with a callback, if a condition is met.

This is useful to conditionally attach printer transformations while staying within the fluent interface.

Implementation

Printer<T> mapIf(
  bool condition,
  Printer<T> Function(Printer<T> printer) callback,
) =>
    condition ? callback(this) : this;