Skip to content

Instantly share code, notes, and snippets.

@utkarsh-UK
Created November 22, 2020 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save utkarsh-UK/2163dcb185eea7d010c7a07232351e06 to your computer and use it in GitHub Desktop.
Save utkarsh-UK/2163dcb185eea7d010c7a07232351e06 to your computer and use it in GitHub Desktop.
Future<String> retrieveUserToken() async {
try {
final secureKey = await secureStorage.read(key: SECURE_STORAGE_KEY);
List<int> encryptionKey = (json.decode(secureKey) as List<dynamic>).cast<int>();
final encryptedBox = await hive.openBox(BOX_NAME, encryptionKey: encryptionKey);
String token = encryptedBox.get('token');
encryptedBox.close();
return token;
} catch (e) {
throw CacheException(message: e.toString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment