Integrate Firebase (Auth, Firestore, Storage) in Flutter
✓Works with OpenClaudeYou are a Flutter developer. The user wants to integrate Firebase services (Authentication, Firestore database, and Cloud Storage) into a Flutter application.
What to check first
- Run
flutter doctorto verify Flutter SDK and Android/iOS setup are complete - Check
pubspec.yamlto see iffirebase_core,firebase_auth,cloud_firestore, andfirebase_storagepackages are already listed - Verify you have a Firebase project created in the Firebase Console with Android and iOS apps registered
Steps
- Add Firebase packages to
pubspec.yaml:firebase_core,firebase_auth,cloud_firestore,firebase_storage, andproviderfor state management - Run
flutter pub getto download dependencies - Initialize Firebase in
main.dartusingFirebase.initializeApp()before running the app - Create an
AuthServiceclass to handleFirebaseAuthsign-up, login, logout, and password reset methods - Create a
FirestoreServiceclass to implement CRUD operations (create, read, update, delete) on Firestore collections - Create a
StorageServiceclass to upload files to Firebase Storage and retrieve download URLs - Wrap your app with
ChangeNotifierProviderfor state management of auth and data streams - Use
StreamBuilderwidgets to listen to real-time Firestore and authentication state changes
Code
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_storage/firebase_storage.dart';
import 'package:provider/provider.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
class AuthService with ChangeNotifier {
final FirebaseAuth _auth = FirebaseAuth.instance;
Stream<User?> get authStateChanges => _auth.authStateChanges();
Future<UserCredential> signup(String email, String password) async {
return await _auth.createUserWithEmailAndPassword(
email: email,
password: password,
);
}
Future<UserCredential> login(String email, String password) async {
return await _auth.signInWithEmailAndPassword(
email: email,
password: password,
);
}
Future<void> logout() async {
await _auth.signOut();
}
}
class FirestoreService {
final FirebaseFirestore _db = FirebaseFirestore.instance;
Future<void> addUser(String uid, String name, String email) async {
await _db.collection('users').doc(uid).set({
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Flutter Skills
Other Claude Code skills in the same category — free to download.
Flutter Widget
Build custom Flutter widgets with state management
Flutter Riverpod
Set up Riverpod for state management in Flutter
Flutter Navigation
Configure GoRouter for declarative navigation
Flutter HTTP
Build HTTP client with Dio and interceptors
Flutter Testing
Write widget tests and integration tests for Flutter
Flutter State Management with Riverpod
Manage app state in Flutter using Riverpod 2.x for type-safe reactive state
Flutter Platform Channels
Call native iOS and Android code from Flutter via platform channels
Want a Flutter skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.