Create GCP Project & Billing
The foundation of our cloud infrastructure starts with a Google Cloud Platform project.
- Go to the GCP Console.
- Click New Project and enter
my-variance-analysis. - Navigate to Billing in the side menu.
- Click Link a Billing Account to ensure the project can use paid services like Document AI and Firebase beyond free tiers.
Initialize Firebase
Firebase provides our real-time database, authentication, and hosting capabilities.
A. Create Firebase Project
Go to Firebase Console and click Add Project. Select your existing GCP project from the dropdown.
B. Database & Authentication
- Firestore: Click "Create Database", choose "Production Mode", and select a region (e.g., us-central1).
- Authentication: Enable "Email/Password" and "Google" sign-in providers under the Build > Authentication menu.
FlutterFire CLI Configuration
Modern Flutter development uses the CLI to automatically generate configuration files.
A. Prerequisites
Ensure you have the Firebase tools installed globally:
dart pub global activate flutterfire_cli
B. Configuration Command
Run this in your project root to fetch configs and generate code:
Select your project (my-variance-analysis) and platforms (Android, iOS) when prompted.
C. Generated Files
- firebase_options.dart: Created in
lib/. Contains API keys and app IDs for initializing Firebase in Dart code. - firebase.json: Created in project root. Maps your app services (Hosting, Functions, etc.) to the project.
Manual App Registration (Legacy/Alternative)
If not using the CLI, register your iOS and Android applications manually to receive configuration files.
Android Setup
Register package com.example.myvarianceanalysis and download google-services.json.
iOS Setup
Register bundle ID com.example.myvarianceanalysis and download GoogleService-Info.plist.
Manual Project File Integration
Correct placement of the .plist and .json files is critical if manually configuring.
iOS Integration (Xcode)
Move GoogleService-Info.plist into the ios/Runner directory.
Important: You must open the project in Xcode, right-click the Runner folder, and select "Add Files to Runner" to ensure the file is linked to the build target.
Android Integration
Place google-services.json in the android/app/ directory.
Authentication Implementation
Integrating native login flows and user verification directly within the Flutter app.
A. Dependencies
Add these packages to your pubspec.yaml:
B. Email/Password Authentication
Standard flow for creating and signing in users with email and password:
try {
final credential = await FirebaseAuth.instance.createUserWithEmailAndPassword(
email: emailAddress,
password: password,
);
} on FirebaseAuthException catch (e) {
if (e.code == 'weak-password') {
print('The password provided is too weak.');
} else if (e.code == 'email-already-in-use') {
print('The account already exists for that email.');
}
}
// Sign in existing user
try {
final credential = await FirebaseAuth.instance.signInWithEmailAndPassword(
email: emailAddress,
password: password,
);
} on FirebaseAuthException catch (e) {
if (e.code == 'user-not-found') {
print('No user found for that email.');
} else if (e.code == 'wrong-password') {
print('Wrong password provided for that user.');
}
}
C. Email Verification
Send a verification email to the current user and check their status:
await FirebaseAuth.instance.currentUser?.sendEmailVerification();
// Check verification status (reload user first)
await FirebaseAuth.instance.currentUser?.reload();
if (FirebaseAuth.instance.currentUser!.emailVerified) {
print('User is verified');
}
Full Source Code & Infrastructure
The complete infrastructure-as-code (Terraform) for GCP creation and the full Flutter application source code is available on our GitLab repository.
View Project on GitLabVisit this for detailed data on infrastructure creation and the final application implementation.