ToString class Null safety

Annotation for generating toString method.

By default, toString only contain public field exclude getter.

You can annotate ToString to getters to let them shown in toString

/// cat.dart

part 'cat.g.dart';

@ToString()
class Cat {
  var color = "white";
  var _heart = "warm";

  @ToString()
  bool get hasWings => false;

  @override
  String toString() {
    // return "Cat{color: white}"
    return _$CatToString(this);
  }
}

Constructors

ToString({bool? prettyPrint, String? indent})
If prettyPrint is set to true, indent will be default to " ". Otherwise, indent will be ""
const

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
indent String?
The line indent
final
prettyPrint bool?
Enable pretty print
final
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
A string representation of this object. [...]
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited