Overview of hive_ce_inspector
mainhive_ce_inspector is a specialized tool designed to inspect Hive CE boxes. It provides a way to view and interact with the data stored within Hive CE structures.repository·main·Indexed 43 days ago
https://github.com/io-design-team/hive_ceA high-performance, pure-Dart key-value NoSQL database designed for cross-platform applications (mobile, desktop, web). A modern continuation of Hive v2, it features a DevTools extension for box inspection, Isolate support via IsolatedHive, Flutter web WASM support, and automatic adapter generation using the @GenerateAdapters annotation.
hive_ce_inspector is a specialized tool designed to inspect Hive CE boxes. It provides a way to view and interact with the data stored within Hive CE structures.Hive CE extends the original Hive v2 with several modern features:
IsolatedHive to support multiple isolates.@GenerateAdapters annotation to automatically generate type adapters for classes, including those outside the current package.223 to 65439.Set types, a built-in Duration adapter, and Freezed support.Hive CE requires Dart 3. Ensure your pubspec.yaml environment configuration meets this requirement:
environment:
sdk: ^3.0.0To change the launch screen image for the iOS version of your Flutter application, you can use one of two methods:
Replace the existing image files directly within the hive_flutter/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/ directory with your own assets.
open ios/Runner.xcworkspace from your terminal.Runner/Assets.xcassets.open ios/Runner.xcworkspaceThe HiveSchema class is a JSON-serializable representation of the schema used to support incremental changes in Hive adapters. It tracks the global state of type IDs and individual type definitions to ensure safe schema evolution.
nextTypeId: An integer representing the next available ID for a new type.types: A map where keys are type names (Strings) and values are HiveSchemaType objects.This schema is typically used by Hive CE tools to manage migrations and ensure that new fields or types do not conflict with existing ones.
const schema = HiveSchema(
nextTypeId: 1,
types: {
'User': HiveSchemaType(
typeId: 0,
nextIndex: 1,
fields: {
'name': HiveSchemaField(index: 0),
},
),
},
);A Box is the primary container for data in Hive. Each box acts as a key-value store.
Key Characteristics:
Future), but new values are immediately available in memory. The Future completes once the change is persisted to the backend.LazyBox instances, read operations are asynchronous.isOpen == true). Closing a box via close() affects all instances of that box across your application.The Hive CE Inspector is designed to run as a DevTools extension. To launch the inspector, the application entry point uses DevToolsExtension from the devtools_extensions package to wrap the ConnectionScreen widget. This allows the inspector to be integrated into the Flutter DevTools environment.
void main() {
runApp(const DevToolsExtension(child: ConnectionScreen()));
}Hive boxes can be used similarly to a Dart Map. Most operations do not require awaiting Futures for synchronous-style access to the data stored in the box.
import 'package:hive_ce/hive_ce.dart';
void example() {
final box = Hive.box('myBox');
box.put('name', 'David');
final name = box.get('name');
print('Name: $name');
}Use these methods to remove data from a box.
// Delete a specific key (does nothing if key doesn't exist)
await box.delete('my_key');
// Delete the entry at a specific index
await box.deleteAt(5);
// Delete multiple specific keys
await box.deleteAll(['key1', 'key2']);
// Remove all entries from the box
int removedCount = await box.clear();Use these methods to manage the state of the box and its physical storage.
// Flush pending changes to disk
await box.flush();
// Manually trigger compaction (rarely needed)
await box.compact();
// Close the box (affects all instances of this box)
await box.close();
// Completely remove the box file/database from disk and close it
await box.deleteFromDisk();Use the following methods to persist data to a box. Note that while these return Future<void>, the data is immediately available for reading in memory.
// Save a single key-value pair
await box.put('name', 'John Doe');
// Save a value at a specific index (throws if index doesn't exist)
await box.putAt(0, 'First Value');
// Save multiple entries at once
await box.putAll({'id': 1, 'status': 'active'});
// Add a value with an auto-incrementing key
int newKey = await box.add('New Entry');
// Add multiple values with auto-incrementing keys
Iterable<int> newKeys = await box.addAll(['Val 1', 'Val 2']);