shouldRegenerate static method
Determines if Firebase configuration regeneration is needed.
Checks if the existing firebase_options.dart file contains the correct project ID. If not, regeneration is required.
Parameters:
projectId: The Firebase project ID to check foroutput: Optional output path for firebase_options.dart
Returns: true if regeneration is needed, false otherwise
Example:
// Check if Firebase configuration needs regeneration
final needsRegen = FirebaseHelper.shouldRegenerate('my-project-id');
if (needsRegen) {
print('Firebase configuration needs to be regenerated');
// Run flutterfire configure command
}
Implementation
static bool shouldRegenerate(String projectId, String? output) {
final pathFirebaseOptions = output != null
? join(current, output)
: join(current, 'lib', 'firebase_options.dart');
if (exists(pathFirebaseOptions)) {
final firebaseOptions = readFile(pathFirebaseOptions);
if (RegExp('''projectId:(\\s+)?('|")$projectId('|")''')
.hasMatch(firebaseOptions)) {
return false;
}
}
return true;
}