shouldNotIncludeLibrary method
Parameters:
uri
: The library URI to check- loader: The RuntimeScannerConfiguration configuration
- onError: Error callback function
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));
}