accessibility
Use when working on accessibility, a11y, WCAG, ARIA, screen readers, keyboard nav, focus order, contrast, alt text, captions,…
Use when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules.
Claude Code
$ npx -y skills add evanca/flutter-ai-rules --skill firebase-database --agent claude-code
Codex
$ npx skills add evanca/flutter-ai-rules --skill firebase-database -a codex -y
Cursor
$ npx skills add evanca/flutter-ai-rules --skill firebase-database -a cursor -y
Gemini CLI
$ npx skills add evanca/flutter-ai-rules --skill firebase-database -a gemini-cli -y
GitHub Copilot
$ npx skills add evanca/flutter-ai-rules --skill firebase-database -a github-copilot -y
OpenCode
$ npx skills add evanca/flutter-ai-rules --skill firebase-database -a opencode -y
Windsurf
$ npx skills add evanca/flutter-ai-rules --skill firebase-database -a windsurf -y
name: firebase-database description: "Use when syncing real-time data, structuring JSON trees, reading/writing, creating listeners, enabling offline persistence, managing presence, sharding, or writing security rules." license: MIT
This skill defines how to correctly implement Firebase Realtime Database in Flutter applications, covering data modeling, queries, real-time sync, offline support, and security rules.
Use this skill when working with Firebase Realtime Database for **simple data models**, **low-latency sync**, or **presence functionality**. For rich data models requiring complex queries and high scalability, use Cloud Firestore instead.
---
Choose **Realtime Database** when the app needs:
Choose **Cloud Firestore** instead for rich data models requiring queryability, scalability, and high availability.
---
flutter pub add firebase_database
import 'package:firebase_database/firebase_database.dart'; // After Firebase.initializeApp(): final DatabaseReference ref = FirebaseDatabase.instance.ref();
FirebaseDatabase.instance.setPersistenceEnabled(true); FirebaseDatabase.instance.setPersistenceCacheSizeBytes(10000000); // 10MB
1. Confirm `Firebase.initializeApp()` completes before accessing `FirebaseDatabase.instance`. 2. Set persistence **before** any read/write operations. 3. Verify connectivity by writing a test value and reading it back.
---
final newPostKey = FirebaseDatabase.instance.ref().child('posts').push().key;// Instead of nesting chat messages inside rooms:
// rooms/roomId/messages/messageId/...
// Flatten into separate top-level paths:
// rooms/roomId: { name: "General", createdBy: "uid1" }
// room-members/roomId: { uid1: true, uid2: true }
// room-messages/roomId/messageId: { text: "Hello", sender: "uid1", timestamp: ... }This pattern allows reading room metadata without downloading all messages.
---
{
"rules": {
"dinosaurs": {
".indexOn": ["height", "length"]
}
}
}final query = FirebaseDatabase.instance.ref("dinosaurs").orderByChild("height");final query = ref.orderByChild("height").limitToFirst(10);// Find users whose name starts with "A"
final query = ref.child("users")
.orderByChild("name")
.startAt("A")
.endAt("A\uf8ff");---
**Read once:**
final snapshot = await FirebaseDatabase.instance.ref('users/123').get();
if (snapshot.exists) {
print(snapshot.value);
}**Real-time listener:**
final subscription = FirebaseDatabase.instance
.ref('users/123')
.onValue
.listen((event) {
final data = event.snapshot.value;
print(data);
});
// Cancel when no longer needed:
subscription.cancel();A `DatabaseEvent` fires every time data changes at the reference, including changes to children.
**Write (replace):**
await ref.set({
"name": "John",
"age": 18,
"created_at": ServerValue.timestamp,
});**Update (partial):**
await ref.update({"age": 19});**Atomic transaction:**
final result = await FirebaseDatabase.instance
.ref('posts/123/likes')
.runTransaction((currentValue) {
return Transaction.success((currentValue as int? ?? 0) + 1);
});
print('Likes: ${result.snapshot.value}');**Multi-path atomic update:**
final updates = <String, dynamic>{
'posts/$postId': postData,
'user-posts/$uid/$postId': postData,
};
await FirebaseDatabase.instance.ref().update(updates);---
await FirebaseDatabase.instance.ref('posts/123/timestamp').set(ServerValue.timestamp);---
FirebaseDatabase.instance.setPersistenceEnabled(true);
// Keep critical paths synced when offline
FirebaseDatabase.instance.ref('important-data').keepSynced(true);36 Flutter and Dart skills your coding agent loads by itself, sourced only from official documentation. A skill is a folder with a SKILL.md file.
Use when working on accessibility, a11y, WCAG, ARIA, screen readers, keyboard nav, focus order, contrast, alt text, captions,…
Use when creating a feature, designing folder structure, adding repositories/services/view models, wiring dependency injection,…
Use when creating a Cubit or Bloc, modeling state with sealed classes or status enums, wiring…
Use when asked to review a PR, MR, branch, or diff, audit changed files, or check code quality.
Use when writing switch statements, refactoring if-else chains, creating data classes, choosing records vs classes, destructuring…
Use when building AI agents in Dart, implementing Genkit flows or tools, integrating LLMs into Dart or Flutter applications, or…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.