DartFile constructor
Implementation
DartFile({
required super.basename,
required super.content,
List<PartFile> parts = const [],
}) : parts = parts.map((e) {
if (e.path.isEmpty) {
throw Exception('Part file path cannot be empty.');
}
for (final partPath in e.path) {
if (partPath.isEmpty) {
throw Exception('Part file path cannot contain empty parts.');
}
if (partPath.contains(RegExp(r'\\|\/|\.\\|\.{2,}|^\.'))) {
throw Exception('Part file path cannot contain relative paths.');
}
}
if (e.path.last.endsWith('.dart')) {
throw Exception('Part file path must not end with .dart.');
}
return e;
}).toList(),
super(extension: 'dart') {
for (final part in parts) {
part.parent = this;
}
}