COMPACT property

ToStringOptions COMPACT
final

Compact format: parameter names excluded, single-line format.

Configuration options for customizing toString output in JetLeaf objects.

Used together with EqualsAndHashCode and the equalizer utility to control how objects are represented as strings. This allows fine-grained control over:

  • Parameter naming (automatic, type-based, or custom)
  • Multi-line vs compact formatting
  • Inclusion/exclusion of class names
  • Custom separators

Predefined Formats

Example

class User implements EqualsAndHashCode {
  final String id;
  final String name;

  User(this.id, this.name);

  @override
  List<Object?> equalizedProperties() => [id, name];
}

void main() {
  final user = User('1', 'Alice');
  print(equalizer.toString(user, ToStringOptions.STANDARD));
  // => User(id: 1, name: Alice)

  print(equalizer.toString(user, ToStringOptions.COMPACT));
  // => User(1, Alice)
}

Implementation

static final COMPACT = ToStringOptions(includeParameterNames: false);