Architecture & Data · 9 min read · Beginner
Local Persistence: SharedPreferences & SQLite
Persist user preferences with shared_preferences and structured offline records with sqflite or Drift.
What you'll learn
- Store simple key-value settings (theme, onboarding) in SharedPreferences
- Store relational offline records in SQLite (sqflite/Drift)
- Store auth tokens securely in flutter_secure_storage instead of plain prefs
Overview
Persist user preferences with shared_preferences and structured offline records with sqflite or Drift.
Code Example
final prefs = await SharedPreferences.getInstance();
await prefs.setBool('darkMode', true);
final isDark = prefs.getBool('darkMode') ?? false;
Key Takeaways
- Store simple key-value settings (theme, onboarding) in SharedPreferences
- Store relational offline records in SQLite (sqflite/Drift)
- Store auth tokens securely in flutter_secure_storage instead of plain prefs
Quick Check
Check Your Understanding
Score: 0 / 1
1. Where should sensitive JWT or session tokens be stored on a Flutter mobile device?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.