encrypt_shared_preferences 0.5.0
encrypt_shared_preferences: ^0.5.0 copied to clipboard
When you use EncryptedSharedPreferences, the data is encrypted before being stored, and it is decrypted when retrieved. This adds an extra layer of protection to sensitive information like user creden [...]
example/lib/main.dart
import 'package:encrypt_shared_preferences/provider.dart';
import 'package:flutter/material.dart';
void main() async {
await EncryptedSharedPreferences.initialize('1111111111111111',
algorithm: EncryptionAlgorithm.salsa20);
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SharedBuilder(
listenKeys: const {"key1", "key2"}, //Optional
builder: (EncryptedSharedPreferences encryptedSharedPreferences) {
return Text(
"value : ${encryptedSharedPreferences.getString("key1")}");
},
),
appBar: AppBar(
title: const Text('Shared Builder Demo'),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
EncryptedSharedPreferences.getInstance()
.setString('key1', 'dataValue');
Future.delayed(const Duration(seconds: 3), () {
EncryptedSharedPreferences.getInstance()
.setString('key2', 'dataValue');
});
},
),
),
);
}
}