processFileIfChanged static method

Future<void> processFileIfChanged(
  1. File file
)

Processes file only if it has changed

Implementation

static Future<void> processFileIfChanged(File file) async {
  final filePath = file.path;
  final lastModified = await file.lastModified();

  if (_fileModificationCache[filePath] == lastModified) {
    return; // File hasn't changed
  }

  _fileModificationCache[filePath] = lastModified;

  final contents = await file.readAsString();

  await processProviderFile(contents, file);
}