What are all the different database you have used ? (like firebase , sql (sqfite) , app write , mango db)
#database#firebase
Answer
Overview
Flutter supports a wide range of databases depending on the use case — local storage, cloud, or relational. Here's a breakdown of the most popular options.
Databases Comparison
| Database | Type | Storage | Best For |
|---|---|---|---|
| Firebase Firestore | NoSQL (Cloud) | Cloud | Real-time sync, scalable apps |
| Firebase Realtime DB | NoSQL (Cloud) | Cloud | Simple real-time data |
| SQLite (sqflite) | Relational (SQL) | Local | Structured local data |
| Hive | NoSQL (Key-Value) | Local | Fast local storage, offline apps |
| Isar | NoSQL (Local) | Local | High-performance local DB |
| Drift (moor) | SQL (ORM) | Local | Type-safe SQL in Flutter |
| AppWrite | BaaS (NoSQL) | Cloud/Self-hosted | Open-source Firebase alternative |
| MongoDB (Atlas) | NoSQL (Cloud) | Cloud | Document-based large-scale apps |
| Shared Preferences | Key-Value | Local | Simple settings/preferences |
| ObjectBox | Object | Local | Very fast local storage |
1. Firebase Firestore (Most Popular)
dartimport 'package:cloud_firestore/cloud_firestore.dart'; // Add document await FirebaseFirestore.instance.collection('users').add({ 'name': 'John', 'email': 'john@example.com', }); // Read documents final snapshot = await FirebaseFirestore.instance .collection('users') .get(); for (var doc in snapshot.docs) { print(doc.data()); } // Real-time stream FirebaseFirestore.instance .collection('users') .snapshots() .listen((snapshot) { // Auto-updates when data changes });
2. SQLite (sqflite)
dartimport 'package:sqflite/sqflite.dart'; // Open database final db = await openDatabase( 'my_database.db', version: 1, onCreate: (db, version) async { await db.execute( 'CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, email TEXT)', ); }, ); // Insert await db.insert('users', {'name': 'Alice', 'email': 'alice@example.com'}); // Query final List<Map<String, dynamic>> users = await db.query('users'); // Update await db.update('users', {'name': 'Bob'}, where: 'id = ?', whereArgs: [1]); // Delete await db.delete('users', where: 'id = ?', whereArgs: [1]);
3. Hive (Fast Local Key-Value)
dartimport 'package:hive_flutter/hive_flutter.dart'; await Hive.initFlutter(); final box = await Hive.openBox('settings'); // Write box.put('theme', 'dark'); // Read final theme = box.get('theme'); // 'dark' // Delete box.delete('theme');
4. AppWrite
dartimport 'package:appwrite/appwrite.dart'; final client = Client() .setEndpoint('https://cloud.appwrite.io/v1') .setProject('YOUR_PROJECT_ID'); final databases = Databases(client); // Create document await databases.createDocument( databaseId: 'db_id', collectionId: 'collection_id', documentId: ID.unique(), data: {'name': 'John'}, );
When to Use What
| Scenario | Recommended DB |
|---|---|
| Simple config/settings | Shared Preferences or Hive |
| Structured relational local data | sqflite or Drift |
| Real-time cloud sync | Firebase Firestore |
| Offline-first with sync | Firestore + local cache |
| Self-hosted backend | AppWrite |
| High performance local | Isar or ObjectBox |
| Large-scale document storage | MongoDB Atlas |
Pro Tip: For most Flutter apps, the combination of Hive (local) + Firebase Firestore (cloud) covers 90% of use cases with minimal boilerplate.