unified_local_data 1.1.1
unified_local_data: ^1.1.1 copied to clipboard
A universal, engine-agnostic local database abstraction layer for Flutter.
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
}