PhysicalFileProvider constructor

PhysicalFileProvider(
  1. String root, {
  2. PhysicalFileProviderOptions? options,
})

Creates a new instance of PhysicalFileProvider at the given root directory.

The root path must be an absolute path.

Implementation

PhysicalFileProvider(
  String root, {
  PhysicalFileProviderOptions? options,
})  : _root = p.absolute(root),
      options = options ?? PhysicalFileProviderOptions(),
      _watcher = PhysicalFilesWatcher(
        p.absolute(root),
        !(options?.usePollingFileWatcher ?? false),
        pollingInterval:
            options?.pollingInterval ?? const Duration(seconds: 4),
      ) {
  if (!p.isAbsolute(root)) {
    throw ArgumentError.value(
      root,
      'root',
      'Root path must be an absolute path.',
    );
  }
}