omni_kv_shared_preferences 0.1.0 copy "omni_kv_shared_preferences: ^0.1.0" to clipboard
omni_kv_shared_preferences: ^0.1.0 copied to clipboard

SharedPreferences adapter for the OmniKV framework.

OmniKV: SharedPreferences #

pub package

The official shared_preferences adapter for OmniKV.

Installation #

You must install both the adapter and the underlying storage package:

flutter pub add omni_kv omni_kv_shared_preferences shared_preferences

Quick Start #

Initialize your KvGateway with the SharedPreferencesKvAdapter:

import 'package:omni_kv/omni_kv.dart';
import 'package:omni_kv_shared_preferences/omni_kv_shared_preferences.dart';
import 'package:shared_preferences/shared_preferences.dart';

Future<void> main() async {
  final prefs = await SharedPreferences.getInstance();
  
  final kv = KvGateway(
    SharedPreferencesKvAdapter(
      prefs,
      codec: const SharedPreferencesKvCodec(prefix: 'my_app.'),
    ),
  );

  // Ready to use!
}

Features & Limitations #

  • Native Types: This adapter natively supports String, int, double, bool, and List<String>.
  • Complex Types: To store custom objects, records, or maps, you must attach a JsonConverter, ModelConverter, or RecordConverter to your KvKey.
  • Scoped Clearing: If you provide a prefix to the codec (e.g., 'my_app.'), calling kv.clear() will only delete keys that start with that prefix. Keys created by other packages will remain completely safe.

For full documentation on how to define keys and use the fluent API, see the core OmniKV package.

0
likes
150
points
78
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

SharedPreferences adapter for the OmniKV framework.

Homepage
Repository (GitHub)
View/report issues

Topics

#shared-preferences #key-value #storage #preferences

License

MIT (license)

Dependencies

flutter, omni_kv, shared_preferences

More

Packages that depend on omni_kv_shared_preferences