cloud_sync_shared_preferences_adapter 0.0.1-rc.1
cloud_sync_shared_preferences_adapter: ^0.0.1-rc.1 copied to clipboard
A Flutter plugin for integrating Shared Preferences sync functionality.
CloudSyncSharedPreferencesAdapter #
A local implementation of the SyncAdapter
interface from the cloud_sync
package, using SharedPreferences
for lightweight key-value storage. This adapter enables basic note syncing and metadata storage directly on the device.
✨ Features #
- Stores note metadata (
SyncMetadata
) and note content (String
) usingSharedPreferences
. - Ideal for quick local persistence and prototyping.
- Lightweight and easy to integrate with local sync flows.
📦 Installation #
Add dependencies in your pubspec.yaml
:
dependencies:
shared_preferences:
cloud_sync:
cloud_sync_shared_preferences_adapter:
🚀 Usage #
import 'package:shared_preferences/shared_preferences.dart';
import 'package:cloud_sync/cloud_sync.dart';
void main() async {
final prefs = await SharedPreferences.getInstance();
final adapter = CloudSyncSharedPreferencesAdapter(prefs);
}
📁 Class Overview #
class CloudSyncSharedPreferencesAdapter
implements SyncAdapter<SyncMetadata, String>
fetchMetadataList()
: Retrieves a list ofSyncMetadata
stored in preferences.fetchDetail(metadata)
: Returns the note content (String
) for the given metadata ID.save(metadata, detail)
: Adds or updates a note and its metadata.
⚠️ Notes #
- Uses a key prefix (
CloudSyncSharedPreferencesAdapter
) to namespace stored keys. - Not suited for storing large files or binary data.
- Ideal for testing, offline-first apps, or as a fallback sync layer.
📄 License #
MIT (or your project’s license).