scan abstract method

Defines the contract for a reflection scanner that processes Dart source files, extracts metadata, and optionally persists output.

Used during framework initialization or tooling that requires reflection metadata (e.g., code analyzers, documentation generators, or runtime scanners).

Implementations should handle scanning efficiently and report meaningful summaries including errors, warnings, and informational messages.

Example

final scanner = MyRuntimeScanner();
final loader = RuntimeScanLoader(
  reload: true,
  updatePackages: false,
  updateAssets: true,
  baseFilesToScan: [File('lib/main.dart')],
  packagesToScan: ['package:meta/', 'package:args/'],
);
final summary = await scanner.scan('build/meta', loader);

print(summary.getErrors());

Performs the reflection scan and outputs a RuntimeScannerSummary.

  • loader is the configuration for the scan.
  • source is the root directory to scan. Defaults to Directory.current.
  • args is the build args to use

Returns a Future that resolves to the final RuntimeScannerSummary.

Implementation

Future<RuntimeScannerSummary> scan(RuntimeScannerConfiguration loader, List<String> args, {Directory? source});