writeImports method
- @mustCallSuper
- StringBuffer importBuffer, {
- required ClassElementExtract classExtract,
inherited
Responsible for writing the required imports for the generated class
Implementation
@mustCallSuper
void writeImports(
StringBuffer importBuffer, {
required ClassElementExtract classExtract,
}) {
if (_importsStringBuffer.isEmpty) {
/// Write the Flutter imports first
_importsStringBuffer
..writeln("import 'package:flutter/material.dart';")
..writeln("import 'package:flutter_test/flutter_test.dart';");
}
if (classExtract.classUri == null) return;
final uriImport = "import '${classExtract.classUri.toString()}';";
if (doesNotContainImport(uriImport)) {
_importsStringBuffer.writeln('$uriImport\n\n');
}
if (_requiresFoundation(classExtract)) {
_writeImport("import 'package:flutter/foundation.dart';");
}
for (final import in classExtract.imports ?? {}) {
_writeImport("import '$import';");
}
}