Skip to content

Poorgramer-Zack/dart-expert-skills / skills/firebase

integrating-firebase

Verified

Firebase integration for Flutter including Auth, Firestore, FCM, Cloud Storage, Analytics, and Crashlytics. Use when implementing serverless backend features, real-time sync, or push notifications.

FileKindSize
SKILL.mdskill md3.0 KB
references/analytics-crashlytics.mdmarkdown3.0 KB
references/app-check.mdmarkdown2.9 KB
references/auth.mdmarkdown6.2 KB
references/cost.mdmarkdown4.2 KB
references/database.mdmarkdown3.5 KB
references/messaging.mdmarkdown4.2 KB
references/serverpod-bff.mdmarkdown4.3 KB
references/setup.mdmarkdown2.7 KB
references/storage.mdmarkdown2.8 KB

references/setup.md

View on GitHub
---
metadata:
  last_modified: "2026-03-12 11:18:17 (GMT+8)"
---

# 01 - Firebase Core Setup (`firebase_core`)

## Goal
Initialize the Firebase SDK reliably across all Flutter platforms. This chapter focuses on eliminating manual native configuration files by enforcing the usage of `flutterfire_cli`, ensuring a seamless and deterministic setup process.

## Instructions

> **Version notes:** firebase_core 5 bumps the Firebase iOS SDK to 13 and the Android BoM to 35. firebase_auth 7 requires macOS 11+ for Swift packages and Android minSdk 24.

### 1. Mandatory CLI Initialization
Never manually download or move `GoogleService-Info.plist` (iOS) or `google-services.json` (Android). They do not configure Dart-only platforms (Web, macOS, Windows) and frequently break native build processes.

**Rule**: Always use the `flutterfire_cli`.
```bash
# 1. Activate the CLI globally
dart pub global activate flutterfire_cli

# 2. Run configure in the project root
flutterfire configure --project=your-firebase-project-id
```
This generates `lib/firebase_options.dart` containing all platform-specific keys natively injected into Dart.

### 2. Dart Initialization Sequence
Initialize Firebase optimally inside `main.dart` *before* `runApp`.

```dart
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'firebase_options.dart'; // Auto-generated by flutterfire_cli

void main() async {
  // CRITICAL: Ensure native bindings are initialized before Firebase
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize Firebase purely through Dart
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  runApp(const MyApp());
}
```

### 3. iOS/macOS Specific Constraints (CRITICAL)

When building for Apple platforms, the massive number of Firebase dependencies can frequently break the CocoaPods build process due to deployment target mismatches.

**Rule (`ios/Podfile` & `macos/Podfile`)**: 
1. The global platform target MUST be explicitly set (usually iOS 13.0+ or macOS 10.15+).
2. You MUST utilize static frameworks by uncommenting or adding `use_frameworks! :linkage => :static`. Dynamic linkage drastically slows down app startup time with Firebase.

```ruby
# Uncomment this line to define a global platform for your project
platform :ios, '15.0' # Matches the Flutter 3.47 template default; keep it equal to your deployment target

target 'Runner' do
  # CRITICAL for Firebase:
  use_frameworks! :linkage => :static

  # ...
end
```

## Constraints
*   **Version Alignments:** Ensure that the `firebase_core` package version aligns with the other specific Firebase packages (like `firebase_auth`, `cloud_firestore`) you are installing. Use the `firebase_core` changelog to determine breaking cross-package changes.
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall