Implementation
@override
String get content {
final content = super.content;
final partDirectives =
parts.map((part) => "part '${part.fileName}';").toList()..sort();
final partString = partDirectives.join('\n');
// inject part directives after all import statements
final importIndex = content.lastIndexOf('import');
var importStatements = '';
var contentWithoutImports = content;
if (importIndex != -1) {
final importEndIndex = content.indexOf(';', importIndex);
importStatements = content.substring(0, importEndIndex + 1);
contentWithoutImports = content.substring(importEndIndex + 1);
}
final trimmed = '''
$importStatements
$partString
$contentWithoutImports'''
.trim();
return '$trimmed\n';
}