ToStringOptions constructor

ToStringOptions({
  1. bool includeParameterNames = true,
  2. bool useNewlines = false,
  3. String? customSeparator,
  4. bool includeClassName = true,
  5. List<String>? customParameterNames,
  6. String customParameterNameGenerator(
    1. Object? value,
    2. int index
    )?,
})

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

ToStringOptions({
  this.includeParameterNames = true,
  this.useNewlines = false,
  this.customSeparator,
  this.includeClassName = true,
  this.customParameterNames,
  this.customParameterNameGenerator,
});