more ui-as-code (#35393)

* more ui-as-code

* address review comments
This commit is contained in:
Alexandre Ardhuin
2019-07-02 21:11:56 +02:00
committed by GitHub
parent e2a55fe83f
commit 758009ba70
62 changed files with 676 additions and 774 deletions

View File

@@ -531,10 +531,12 @@ linter:
File _writeSection(Section section) {
final String sectionId = _createNameFromSource('sample', section.start.filename, section.start.line);
final File outputFile = File(path.join(_tempDirectory.path, '$sectionId.dart'))..createSync(recursive: true);
final List<Line> mainContents = headers.toList();
mainContents.add(const Line(''));
mainContents.add(Line('// From: ${section.start.filename}:${section.start.line}'));
mainContents.addAll(section.code);
final List<Line> mainContents = <Line>[
...headers,
const Line(''),
Line('// From: ${section.start.filename}:${section.start.line}'),
...section.code,
];
outputFile.writeAsStringSync(mainContents.map<String>((Line line) => line.code).join('\n'));
return outputFile;
}
@@ -820,10 +822,9 @@ class Line {
class Section {
const Section(this.code);
factory Section.combine(List<Section> sections) {
final List<Line> code = <Line>[];
for (Section section in sections) {
code.addAll(section.code);
}
final List<Line> code = sections
.expand((Section section) => section.code)
.toList();
return Section(code);
}
factory Section.fromStrings(Line firstLine, List<String> code) {