Skip to main content

unified_local_data 2.0.0 copy "unified_local_data: ^2.0.0" to clipboard
unified_local_data: ^2.0.0 copied to clipboard

Engine-agnostic local storage for Flutter. One API over Hive, Isar or your own engine, with typed objects, queries, reactive streams and transactions.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:unified_local_data/unified_local_data.dart';
import 'package:path_provider/path_provider.dart';

/// A simple example demonstrating how to use [unified_local_data] with the
/// Hive CE engine.
void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  // Initialize the data source with the Hive engine.
  final dir = await getApplicationDocumentsDirectory();

  final dataSource = await UnifiedDataSourceFactory.create(
    UnifiedDataSourceConfig.hive(
      directory: dir.path,
      preloadBoxes: ['settings', 'cache'],
    ),
  );

  // Put a simple string value.
  await dataSource.put<String>('settings', 'theme', 'dark');

  // Read it back.
  final String? theme = await dataSource.get<String>('settings', 'theme');
  debugPrint('Stored theme: $theme'); // Stored theme: dark
}
1
likes
160
points
46
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Engine-agnostic local storage for Flutter. One API over Hive, Isar or your own engine, with typed objects, queries, reactive streams and transactions.

Repository (GitHub)
View/report issues

Topics

#database #storage #hive #offline #persistence

License

MIT (license)

Dependencies

flutter, hive_ce

More

Packages that depend on unified_local_data