flutter_vault_logger
Secure, encrypted on-device crash log storage for Flutter apps.
Features
- 🔒 AES-256 encrypted export / import of crash logs
- 💾 Hive-backed persistent local storage
- 📱 Automatic device info & app version capture
- 🗂️ Named report management (save, load, share)
- 🔍 Duplicate log detection and deduplication
- ⏱️ Auto-clear after export (configurable expiry window)
Setup
1. Add the dependency
dependencies:
flutter_vault_logger: ^0.1.0
2. Initialise in main()
import 'package:flutter_vault_logger/flutter_vault_logger.dart';
import 'package:hive_flutter/hive_flutter.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await HiveFlutter.initFlutter();
await CrashLogService.init(
VaultLoggerConfig(
encryptionKey: 'YourApp32CharKeyHere!!!!12345678', // exactly 32 chars
encryptionIV: 'YourApp16CharIV!', // exactly 16 chars
fileExtension: 'myapp', // exported files use .myapp extension
),
);
runApp(const MyApp());
}
Example app
A full runnable demo app is included in the example/ folder.
cd example
flutter pub get
flutter run
3. Log errors
try {
...
} catch (e, st) {
await CrashLogService.logError(
e,
stackTrace: st,
context: 'MyWidget.someMethod',
);
}
Configuration (VaultLoggerConfig)
| Parameter | Default | Description |
|---|---|---|
encryptionKey |
required | 32-char AES-256 key |
encryptionIV |
required | 16-char AES IV |
fileExtension |
vaultlog |
Extension of exported encrypted files |
maxLogCount |
100 |
Max logs kept before oldest is evicted |
expirationMinutes |
30 |
Minutes after export before auto-clear (0 = disabled) |
onError |
null |
Optional error callback (defaults to debugPrint) |
Key API
// Logging
await CrashLogService.logError(
error,
stackTrace: stackTrace,
context: 'context label',
);
// Reading
List<CrashLogModel> logs = CrashLogService.getLogs();
// Export / import
String path = await CrashLogService.exportEncryptedLogs();
List<CrashLogModel> imported = await CrashLogService.importEncryptedLogs(path);
// Reports
await CrashLogService.saveReport('User A – Issue 1', logs);
List<CrashReportModel> reports = CrashLogService.getReports();
// Duplicate detection
Map<String, List<CrashLogModel>> dupes = CrashLogService.findDuplicates(logs);
List<CrashLogModel> cleaned = CrashLogService.deduplicateLogs(logs);