shouldNotIncludeLibrary method

  1. @override
Future<bool> shouldNotIncludeLibrary(
  1. Uri uri,
  2. RuntimeScannerConfiguration configuration
)
override

Parameters:

Returns true if the library should be excluded because:

  • It's a Dart core library
  • It matches exclusion patterns
  • It doesn't match inclusion patterns (when specified)

Example:

final exclude = await ReflectUtils.shouldNotIncludeLibrary(
  uri,
  loader,
  (error) => print('Error: $error'),
);

Implementation

@override
Future<bool> shouldNotIncludeLibrary(Uri uri, RuntimeScannerConfiguration configuration) async {
  if (uri.pathSegments.isNotEmpty && uri.pathSegments.first.equalsAny(['analyzer', '_fe_analyzer_shared'])) {
    return true;
  }

  if(configuration.packagesToExclude.any((p) => p == uri.toString())) {
    return true;
  }

  return (uri.pathSegments.isNotEmpty && configuration.packagesToExclude.any((p) => uri.pathSegments.first == p));
}