play_services_block_store 0.0.1
play_services_block_store: ^0.0.1 copied to clipboard
The Block Store API allows your app to store data that it can later retrieve to re-authenticate users on a new device.
play_services_block_store #
A Flutter plugin for accessing the Google Play Services Block Store API on Android. Securely store and retrieve small key-value pairs of data that can survive app uninstall and restore, making it ideal for authentication tokens or device identifiers.
⚠️ Android only. This plugin uses Google Play Services and is not supported on iOS or web.
Features #
- 🔐 Save and retrieve key-value pairs securely.
- 💾 Support for storing both strings and byte arrays (as base64).
- 🔍 Retrieve a single item or all stored items.
- 🗑️ Delete individual keys or clear all stored data.
- 🧩 Easy-to-use Flutter API.
Getting Started #
Installation #
Add this to your pubspec.yaml:
dependencies:
play_services_block_store: ^<latest_version>
Then run:
flutter pub get
Usage #
import 'package:play_services_block_store/play_services_block_store.dart';
final store = PlayServicesBlockStore();
// Save a string
await store.saveString('username', 'alice');
// Retrieve a string
final username = await store.retrieveString('username');
// Save base64-encoded bytes
final base64Data = base64Encode([1, 2, 3, 4]);
await store.saveBytes('my_bytes', base64Data);
// Retrieve base64-encoded bytes
final encoded = await store.retrieveBytes('my_bytes');
// Retrieve all stored values
final allData = await store.retrieveAll();
// Delete a single key
await store.delete('username');
// Delete all stored data
await store.deleteAll();