replaceInFile function

Future<void> replaceInFile(
  1. String path,
  2. dynamic oldPackage,
  3. dynamic newPackage
)

Implementation

Future<void> replaceInFile(String path, oldPackage, newPackage) async {
  String? contents = await readFileAsString(path);
  if (contents == null) {
    print('ERROR:: file at $path not found');
    return;
  }
  contents = contents.replaceAll(oldPackage, newPackage);
  await writeFileFromString(path, contents);
}