toString method
A string representation of this object.
Some classes have a default textual representation,
often paired with a static parse function (like int.parse).
These classes will provide the textual representation as
their string representation.
Other classes have no meaningful textual representation
that a program will care about.
Such classes will typically override toString to provide
useful information when inspecting the object,
mainly for debugging or logging.
Implementation
@override
String toString() {
final strbuf = StringBuffer() //
..writeln(
'${isAsync ? 'Future<void>' : 'void'} ${groupName}Initializer() ${isAsync ? 'async ' : ''}{');
if (_topLevelVariable.isNotEmpty) {
for (final variable in _topLevelVariable) {
strbuf.writeln(
' ${variable.getter?.isAsynchronous == true ? 'await ' : ''}${variable.identifier};');
}
}
if (_initFunction.isNotEmpty) {
for (final fn in _initFunction) {
strbuf.writeln(
' ${fn.isAsynchronous ? 'await ' : ''}${fn.identifier}();');
}
}
if (_initField.isNotEmpty) {
for (final f in _initField) {
final klass = f.enclosingElement as ClassElementImpl;
strbuf.writeln(
' ${f.getter?.isAsynchronous == true ? 'await ' : ''}${klass.identifier}.${f.identifier};');
}
}
if (_initMethod.isNotEmpty) {
for (final m in _initMethod) {
final klass = m.enclosingElement as ClassElementImpl;
strbuf.writeln(
' ${m.isAsynchronous ? 'await ' : ''}${klass.identifier}.${m.identifier}();');
}
}
strbuf.writeln('}');
return strbuf.toString();
}