build method
Implementation
@override
String build() {
assert(body != null || isAbstract);
if (isAbstract) {
return OneLine(depth: depth, body: '${functionSignature()};').build();
}
if (oneLine) {
final lines = <OneLine>[];
if (isOverride) {
lines.add(OneLine(depth: depth, body: '@Override'));
}
final sb = StringBuffer();
sb.write(functionSignature());
sb.write(keywordSpace);
sb.write(keywordBraceLeft);
sb.write(keywordSpace);
sb.write(CodeUnit.join(body!(depth))
.replaceAll(' ', '')
.replaceAll('\n', ''));
sb.write(keywordSpace + keywordBraceRight);
lines.add(OneLine(depth: depth, body: sb.toString()));
return CodeUnit.join(lines);
}
return CodeUnit.join([
if (isOverride) OneLine(depth: depth, body: '@Override'),
OneLine(
depth: depth,
body: functionSignature() + keywordSpace + keywordBraceLeft),
...body!(depth),
OneLine(depth: depth, body: keywordBraceRight)
]);
}