loadOrCreateKey static method
Load existing key or create a new one.
Implementation
static Future<List<int>> loadOrCreateKey() async {
final keyFile = File(_keyFilePath);
if (await keyFile.exists()) {
final encodedKey = await keyFile.readAsString();
return base64Decode(encodedKey);
} else {
final key = _generateRandomKey();
await keyFile.create(recursive: true);
await keyFile.writeAsString(base64Encode(key));
return key;
}
}