hivez library

Hivez

A type-safe, concurrency-safe, production-ready wrapper around Hive CE for Dart & Flutter.

Why Hivez?

  • Zero setup → no openBox, boxes auto-initialize
  • Type-safe → no dynamic, compile-time guarantees
  • Unified API → Box, LazyBox, IsolatedBox — one interface
  • Concurrency-safe → built-in locking, atomic writes
  • Production features → encryption, crash recovery, compaction
  • Utilities included → backup/restore, search, iteration helpers

Box types

  • HivezBox<K, T> → Standard box, fast sync reads
  • HivezBoxLazy<K, T> → Lazy loading for large datasets
  • HivezBoxIsolated<K, T> → Isolate-safe box
  • HivezBoxIsolatedLazy<K, T> → Isolate + lazy combined

Example

final users = HivezBox<int, User>('users');
await users.put(1, User('Alice'));
final u = await users.get(1); // User('Alice')

Full docs & setup guide: https://pub.dev/packages/hivez

Classes

BaseHivezBox<K, T>
Base class for all HivezBox implementations, providing core logic for initialization, locking, logging, and high-level box operations.
Box<K, T>
The Box class provides a convenient, type-safe, and composable API for working with Hive boxes in Dart and Flutter applications. It acts as a decorator over the underlying BoxInterface, allowing you to easily configure, open, and interact with boxes of various types (regular, lazy, isolated, isolated lazy) using a unified interface.
BoxConfig
Immutable configuration for creating or opening a Hive box.
BoxInterface<K, T>
The base interface for all HivezBox types, providing a strongly-typed, production-grade abstraction over Hive boxes.
HivezBox<K, T>
A strongly-typed, non-lazy, non-isolated Hive box implementation.
HivezBoxIsolated<K, T>
A strongly-typed, non-lazy Hive box implementation that operates in an isolated background process for improved performance and safety.
HivezBoxIsolatedLazy<K, T>
A strongly-typed, lazy Hive box implementation that operates in an isolated background process for improved performance and safety.
HivezBoxLazy<K, T>
A strongly-typed, lazy Hive box implementation.
IndexedBox<K, T>
A Box implementation that provides full-text search and secondary indexing.
SortCriterion<T>
Describes a sorting criterion for use with SearchExtensionMethod.search.
TextAnalyzer<T>
Abstract base class for text analyzers used in IndexedBox for tokenization.

Enums

Analyzer
The type of text analyzer to use for tokenizing and indexing values in an IndexedBox.
BoxType
The type of Hive box to create or interact with.

Extensions

BackupCompressedExtension on BoxInterface<K, T>
Extension providing compressed binary backup and restore capabilities for BoxInterface.
BackupJsonExtension on BoxInterface<K, T>
Extension providing JSON backup and restore capabilities for BoxInterface.
CreateBoxFromConfigExtensions on BoxConfig
Extension on BoxConfig to create a Box instance directly.
CreateBoxFromTypeExtensions on BoxType
Extension on BoxType to create a Box with a fluent API.
CreateHivezBoxFromConfig on BoxConfig
Extension to create a BoxInterface from a BoxConfig.
CreateIndexedBoxFromConfig on BoxConfig
Extension on BoxConfig to easily create an IndexedBox with full-text search capabilities.
CreateIndexedBoxFromType on BoxType
Extension on BoxType to create an IndexedBox with full-text search support.
CreateTextAnalyzerExtensions on Analyzer
Extension for creating a TextAnalyzer from an Analyzer enum value.
CreationExtensionsBoxType on BoxType
Extension methods for BoxType to facilitate box creation and configuration. s This allows you to easily create a BoxConfig or a BoxInterface directly from a BoxType value.
GetTypeOfBoxInterfaceExtension on BoxInterface<K, T>
Extension to determine the BoxType of a BoxInterface at runtime.
IndexedBoxSearchExtensions on IndexedBox<K, T>
SearchExtensionMethod on BoxInterface<K, T>
Extension providing advanced search and sorting capabilities for BoxInterface.

Exceptions / Errors

HivezBoxException
Exception thrown for general box-level failures in the Hivez storage system.
HivezException
The base class for all exceptions and errors thrown by the Hivez library.