List getUnsupportedImports()

in lib/src/project.dart [183:208]


List<ImportDirective> getUnsupportedImports(List<ImportDirective> imports,
    {required bool devMode}) {
  return imports.where((import) {
    final uriString = import.uri.stringValue;
    if (uriString == null) {
      return false;
    }
    // All non-VM 'dart:' imports are ok.
    if (uriString.startsWith('dart:')) {
      return !_allowedDartImports.contains(uriString);
    }

    final uri = Uri.tryParse(uriString);
    if (uri == null) return false;

    // We allow a specific set of package imports.
    if (uri.scheme == 'package') {
      if (uri.pathSegments.isEmpty) return true;
      final package = uri.pathSegments.first;
      return !isSupportedPackage(package, devMode: devMode);
    }

    // Don't allow file imports.
    return true;
  }).toList();
}