cloud_sync_hive_adapter 0.0.1-rc.2 copy "cloud_sync_hive_adapter: ^0.0.1-rc.2" to clipboard
cloud_sync_hive_adapter: ^0.0.1-rc.2 copied to clipboard

A Flutter plugin for integrating Hive sync functionality.

CloudSyncHiveAdapter #

A local storage implementation of the SyncAdapter interface from the cloud_sync package, built on top of Hive.
This adapter allows your app to store and sync note metadata and content locally using the Hive database.


✨ Features #

  • πŸ’Ύ Persists metadata (SyncMetadata) and detailed content (String) locally using Hive.
  • πŸ”„ Supports reading, writing, and syncing note data.
  • 🧱 Ideal for offline-first apps or local caching alongside cloud sync (e.g., Google Drive).
  • πŸš€ Fast, lightweight, and key-value based local database.

πŸ“¦ Installation #

Add these dependencies to your pubspec.yaml:

dependencies:
  hive_ce: ^latest
  cloud_sync: ^latest
  cloud_sync_hive_adapter: ^latest

⚠️ Note: Be sure to initialize Hive before usage and register any adapters needed for your metadata class.


πŸš€ Usage #

import 'package:hive_ce/hive.dart';
import 'package:cloud_sync_hive_adapter/cloud_sync_hive_adapter.dart';
import 'your_models/sync_metadata.dart'; // Your custom SyncMetadata

void main() async {
  await Hive.initFlutter();
  
  // Optionally register Hive adapters if needed
  // Hive.registerAdapter(MyMetadataAdapter());

  final metadataBox = await Hive.openBox<String>('metadataBox');
  final detailBox = await Hive.openLazyBox<String>('detailBox');

  final adapter = CloudSyncHiveAdapter<MyMetadata>(
    metadataBox: metadataBox,
    detailBox: detailBox,
    metadataToJson: (meta) => jsonEncode(meta.toJson()),
    metadataFromJson: (json) => MyMetadata.fromJson(jsonDecode(json)),
  );

  // Use the adapter with a CloudSync instance
}

πŸ“ Class Overview #

class CloudSyncHiveAdapter<M extends SyncMetadata>
  extends SerializableSyncAdapter<M, String>

Parameters #

  • metadataBox: A Box<String> used to store serialized metadata.
  • detailBox: A LazyBox<String> for storing note content.
  • metadataToJson / metadataFromJson: Serialization logic for your metadata type.

βœ… When to Use #

  • πŸ“± You need local storage for notes, logs, or structured data.
  • πŸ“΄ Offline-first behavior is important.
  • πŸ”„ You want to combine local persistence with cloud sync (e.g., Google Drive).

πŸ“„ License #

MIT (or your project's license)


  • cloud_sync – Core sync abstraction
  • hive_ce – Lightweight key-value database
2
likes
0
points
122
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for integrating Hive sync functionality.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cloud_sync, hive_ce

More

Packages that depend on cloud_sync_hive_adapter