process method

Future<void> process()

Implementation

Future<void> process() async {
  if (!await File(PATH_BUILD_GRADLE).exists()) {
    print('ERROR:: build.gradle file not found, Check if you have a correct android directory present in your project'
        '\n\nrun " flutter create . " to regenerate missing files.');
    return;
  }
  String? contents = await readFileAsString(PATH_BUILD_GRADLE);

  var reg = RegExp('applicationId "(.*)"', caseSensitive: true, multiLine: false);

  var name = reg.firstMatch(contents!)!.group(1);
  oldPackageName = name;

  print("Old Package Name: $oldPackageName");

  print('Updating build.gradle File');
  await _replace(PATH_BUILD_GRADLE);

  var mText = 'package="$newPackageName">';
  var mRegex = '(package.*)';

  print('Updating Main Manifest file');
  await replaceInFileRegex(PATH_MANIFEST, mRegex, mText);

  print('Updating Debug Manifest file');
  await replaceInFileRegex(PATH_MANIFEST_DEBUG, mRegex, mText);

  print('Updating Profile Manifest file');
  await replaceInFileRegex(PATH_MANIFEST_PROFILE, mRegex, mText);

  await updateMainActivity();
}