Offline
Template for Flutter mobile applications.
npx -y skills add launch52-ai/flutter-template --skill offlineAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 2 stars2 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Offline-first architecture with local storage, sync, and conflict resolution. Use when adding offline support, data synchronization, local caching, or queue-based sync. Supports fully offline apps and online-first apps with offline fallback.
SKILL.md
6.9 KB, as published. Nobody here has run it
Offline - Offline-First Architecture
Implement offline-first architecture with local storage, automatic sync, and conflict resolution. Supports multiple patterns from fully offline apps to online-first with offline fallback.
When to Use This Skill
- Adding offline support to existing features
- Building fully offline-first apps
- Implementing data synchronization
- Adding local caching with sync
- User asks "offline mode", "sync data", "work offline", "cache locally"
When NOT to Use This Skill
- Simple in-memory caching - Use
/datacaching patterns instead - Network connectivity detection - Use
/network-connectivityinstead - Error handling for failed requests - Use
/dataNetworkFailure types
Questions to Ask
- Offline mode: Fully offline-first or online-first with offline fallback?
- Data complexity: Simple key-value or structured relational data?
- Sync strategy: Periodic sync, on-demand, or push-based?
- Conflict resolution: Last-write-wins, server-wins, or custom merge?
- Data sensitivity: Does local data need encryption?
Quick Reference
Offline Patterns
| Pattern | Use When | Local DB | Sync |
|---|---|---|---|
| Fully Offline | Notes, journals, todo apps | Primary | Optional upload |
| Offline-First | Field apps, travel apps | Primary | Background sync |
| Online-First + Fallback | E-commerce, social apps | Cache | On reconnect |
| Cache-Only | Read-heavy feeds | TTL cache | Refresh on pull |
Storage Options
| Storage | Best For | Encryption | Performance |
|---|---|---|---|
| Drift (SQLite) | Relational data, complex queries | AES-256 via SQLCipher | Fast |
| Hive | Key-value, settings, small objects | Built-in AES-256 | Very fast |
| Isar | Large datasets, full-text search | Limited | Fastest |
| SharedPreferences | Flags, simple settings | None | Fast |
| SecureStorage | Tokens, PII | Platform keychain | Slower |
Sync Strategies
| Strategy | Trigger | Best For |
|---|---|---|
| Periodic | Timer (5-15 min) | Background updates |
| On-Demand | User pull-to-refresh | User-controlled sync |
| On-Reconnect | Connectivity change | Offline queue flush |
| Push-Based | FCM/WebSocket | Real-time apps |
| Delta Sync | Timestamp-based | Large datasets |
Conflict Resolution
| Strategy | How It Works | Best For |
|---|---|---|
| Last-Write-Wins (LWW) | Latest timestamp wins | Simple apps, non-critical data |
| Server-Wins | Server always authoritative | Multi-user shared data |
| Client-Wins | Local changes preserved | Single-user apps |
| Custom Merge | Field-level merge logic | Complex business rules |
| User Prompt | Ask user to resolve | Important conflicts |
Workflow
Phase 1: Analyze Requirements
- Determine offline pattern (see Quick Reference)
- Identify data that needs offline access
- Choose storage solution based on data complexity
- Define sync strategy and conflict resolution
Phase 2: Setup Local Storage
- Add dependencies to
pubspec.yaml - Create local database models/tables
- Implement local data source
See: storage-guide.md for detailed setup
Phase 3: Implement Sync Layer
- Add sync status tracking to models
- Create sync queue for pending operations
- Implement sync service with conflict resolution
- Add background sync via WorkManager (optional)
See: sync-guide.md for sync patterns
Phase 4: Update Repository
- Modify repository to read local-first
- Add write-through or write-behind patterns
- Handle sync status in domain entities
- Integrate with connectivity monitoring
Phase 5: Verify
dart run .claude/skills/offline/scripts/check.dart --feature {feature}
Core API
final items = await repository.getAll(); // Local-first read
await repository.create(item); // Saves locally, queues sync
final isSynced = ref.watch(syncStatusProvider);
See: storage-guide.md for dependencies and file structure.
Guides
| File | Content |
|---|---|
| architecture-guide.md | Offline architecture patterns and decisions |
| storage-guide.md | Local storage setup (Drift, Hive) |
| sync-guide.md | Sync strategies and conflict resolution |
Reference Files
See: reference/ for complete implementations:
reference/models/- SyncStatus enum, SyncOperation, OfflineEntity mixinreference/local_storage/- Drift database, Hive local sourcereference/sync/- SyncQueue, SyncService, ConflictResolverreference/repositories/- Offline-first and cache-first patternsreference/providers/- Sync status providers
Checklist
Setup:
- Offline pattern determined (fully offline vs. online-first + fallback)
- Storage solution chosen (Drift/Hive) and added to pubspec.yaml
- Local database/tables created
Models:
- Domain entity has
syncStatusfield - DTO model has sync tracking fields (
localId,updatedAt,isSynced) - Client-generated UUIDs for new entities
Repository:
- Reads from local storage first
- Writes to local storage immediately
- Queues remote sync operations
- Handles sync failures gracefully
Sync:
- Sync queue persists pending operations
- Sync triggers on connectivity restore
- Conflict resolution strategy implemented
- Sync status exposed to UI
Verification:
- Works in airplane mode
- Data persists across app restarts
- Sync completes when online
- Conflicts resolved correctly
Related Skills
/network-connectivity- Connectivity monitoring and offline banner/data- Base repository patterns, caching, error handling/push-notifications- Push-based sync triggers/analytics- Track sync events and failures
Common Issues
| Issue | Solution |
|---|---|
| Data not persisting | Ensure database initialized before use (await AppDatabase.init()) |
| Sync queue grows indefinitely | Implement retry limits and age-based pruning |
| Conflicts overwriting local | Use timestamps for LWW, or user prompts for critical data |
| Slow startup on large datasets | Use pagination, lazy-load details on demand |
See: sync-guide.md for detailed troubleshooting.
Next Steps
After running this skill:
- Run
/network-connectivityfor offline banner - Run
/testingfor offline scenario tests - Run
/i18nfor sync status messages - Consider
/push-notificationsfor push-based sync