Skip to content

Instantly share code, notes, and snippets.

@FTKhanFT
Last active February 5, 2021 23:30
Show Gist options
  • Save FTKhanFT/cc5e5b83b5c7710de3a4facb2f1b718d to your computer and use it in GitHub Desktop.
Save FTKhanFT/cc5e5b83b5c7710de3a4facb2f1b718d to your computer and use it in GitHub Desktop.
How to use cache_x package from the Example project
import 'package:cache_x/cache_x.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Initialize password
// Password length must be 128/192/256 bits
// You can use the password of 16 character,24 character or 32 character.
String password = 'CBoaDQIQAgceGg8dFAkMDBEOECEZCxg=';
// Initialize CacheX with the password
final cacheX = CacheXCore();
await cacheX.init(password: password);
// Saving values
await cacheX.saveBool(key: '1', value: true);
await cacheX.saveDouble(key: '2', value: 10.5);
await cacheX.saveInt(key: '3', value: 30);
await cacheX.saveString(key: '4', value: 'String');
await cacheX.saveStringList(
key: '5',
value: [
'String1',
'String2',
'String3',
],
);
// Getting values
print(cacheX.getBool(
key: '1',
defaultValue: false,
));
print(cacheX.getDouble(key: '2'));
print(cacheX.getInt(key: '3'));
print(cacheX.getString(key: '4'));
print(cacheX.getStringList(key: '5'));
print(cacheX.getKeys());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment