getLibraries method

  1. @override
Future<Map<String, String>> getLibraries(
  1. String source
)
override

Returns a list of files to be included in the compilation process.

Implementation

@override
Future<Map<String, String>> getLibraries(String source) async {
  final libraries = getLibraryNamesToInclude(source);
  // using map ensures that duplicate library dependencies are resolved only once.
  final processed = <String, String>{};

  if (libraries.isEmpty) {
    return processed;
  }

  for (final libraryName in libraries) {
    final librarySourceCode = _getLibraryFile(libraryName);
    if (librarySourceCode.isNotEmpty) {
      processed[libraryName] = librarySourceCode;
      // recursively process the library dependencies.
      processed.addAll(await getLibraries(librarySourceCode));
    }
  }

  return processed;
}