buildApps function
Builds Flutter applications for a specific client ID based on the provided build model.
This function orchestrates the build process for Android (APK/AAB) and iOS (IPA)
platforms. It loads build metadata, prompts the user for confirmation (unless skipped),
and then executes the appropriate flutter build commands.
buildModel A BuildCommandModel containing the client ID and various
flags to control the build process (e.g., buildApk, buildAab,
buildIpa, skipBuildCheck, skipAll).
Throws an Exception if the build metadata cannot be loaded or if any
of the underlying flutter build commands fail.
Implementation
Future<void> buildApps(BuildCommandModel buildModel) async {
final buildMetadata = await _loadBuildMetadata(buildModel.clientId!);
if (buildMetadata == null) {
return;
}
final packageName = buildMetadata['packageName']!;
final appName = buildMetadata['appName']!;
final version = buildMetadata['version']!;
if (buildModel.buildIpa ||
!buildModel.skipBuildCheck ||
!buildModel.skipAll) {
if (!_promptUserForConfirmation(
packageName: packageName,
appName: appName,
version: version,
skipBuildCheck: buildModel.skipBuildCheck,
)) {
return;
}
}
logger.i('🚀 Building apps for client ID: ${buildModel.clientId}');
final stopwatch = Stopwatch()..start();
try {
await _runFlutterBuildCommands(
buildModel: buildModel,
version: version,
stopwatch: stopwatch,
);
logger.i(
'✅ Apps built successfully for client ID: ${buildModel.clientId} in ${(stopwatch.elapsedMilliseconds / 1000).toStringAsFixed(2)}s.',
);
} catch (e) {
// Error is already logged in _runFlutterBuildCommands
} finally {
stopwatch.stop();
}
}