runInAndroid method

Future<void> runInAndroid()

Implementation

Future<void> runInAndroid() async {
  final androidConfigFile = File(androidConfigPath);
  if (!await androidConfigFile.exists()) {
    throw Exception('Android配置文件不存在');
  }
  final lineTexts = await androidConfigFile.readAsLines();
  for (int i = 0; i < lineTexts.length; i++) {
    if (lineTexts[i].contains('flutter.versionName')) {
      lineTexts[i] = 'flutter.versionName=${environment.buildName}';
    } else if (lineTexts[i].contains('flutter.versionCode')) {
      lineTexts[i] = 'flutter.versionCode=${environment.buildNumber}';
    }
  }
  await androidConfigFile.writeAsString(lineTexts.join('\n'));
}