Last active
December 24, 2019 20:25
-
-
Save JEuler/a546a23c982af7ea65454252f6bce9fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Implementation of StorageService using Hive Key-Value DB | |
class StorageServiceImpl implements StorageService { | |
@override | |
Future saveUser(User user) async { | |
final userToSave = DBUser( | |
user.id, | |
user.name, | |
user.avatar); | |
final usersBox = await Hive.openBox('user'); | |
usersBox.put('current_user', userToSave); | |
} | |
@override | |
Future<DBUser> getUser() async { | |
final usersBox = await Hive.openBox('user'); | |
final user = usersBox.get('current_user'); | |
return user; | |
} | |
@override | |
void stop() { | |
Hive.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment