watch method

Future<void> watch()

Implementation

Future<void> watch() async {
  _watchForDependencyChanges();

  final libDirectory = Directory(path.join(Utils.projectDirectory, 'lib'));
  final testDirectory = Directory(path.join(Utils.projectDirectory, 'test'));

  Utils.logHeader(
    'Preparing to watch files in directory: ${Utils.projectDirectory}',
  );

  _generateContentHash(libDirectory);
  _generateContentHash(testDirectory);

  /// perform a first build operation
  await build();

  Utils.logHeader('Watching for file changes.');

  /// let's listen for file changes in the project directory
  /// specifically in "lib" & "test" directory
  libDirectory.watchDartSourceCodeFiles().listen(_onFileSystemEvent);
  testDirectory.watchDartSourceCodeFiles().listen(_onFileSystemEvent);
}