setupFirebaseAuto function
Automated Firebase setup using FlutterFire CLI This command guides users through Firebase setup with real configs
Implementation
Future<void> setupFirebaseAuto() async {
try {
print('');
print('╔════════════════════════════════════════════════════════════════════════════════╗');
print('║ 🔥 Automated Firebase Setup with FlutterFire CLI 🔥 ║');
print('╚════════════════════════════════════════════════════════════════════════════════╝');
print('');
// Get package name and project name
final androidPackageName = _getBasePackageId();
final iosBundleId = _getIosBundleId();
final projectName = getModuleName();
print('${ConsoleSymbols.id}Android Package: $androidPackageName');
if (iosBundleId != androidPackageName) {
print('${ConsoleSymbols.id}iOS Bundle ID: $iosBundleId');
}
print('');
print('');
// Step 1: Pre-flight checks
if (!_checkPrerequisites()) {
return;
}
// Step 2: Check if flavors exist
final hasFlavors = _checkFlavorsExist();
if (hasFlavors) {
print('${ConsoleSymbols.checkmark}Detected flavor-based project');
print(' Setting up Firebase for flavors: dev, stage, prod');
print('');
await _setupFirebaseAutoFlavored(androidPackageName, iosBundleId, projectName);
} else {
print('${ConsoleSymbols.info}No flavors detected - setting up single Firebase configuration');
print('');
await _setupFirebaseAutoSingle(androidPackageName, iosBundleId, projectName);
}
} catch (e) {
print('${ConsoleSymbols.error}Error during Firebase setup: $e');
}
}