d_session 0.0.3
d_session: ^0.0.3 copied to clipboard
Easy way to access Shared Preference and use as Session.
Easy way to access Shared Preference, or we can call like session. For more customization, you can use shared_preferences package.
Features #
1. User #
final user = {
'id': 'aha276avsUHUa',
'email': 'flutter_d_lux@gmail.com',
'username': 'indre',
};
DSession.setUser(user);
DSession.getUser().then((value) {
debugPrint(value.toString());
if (value != null) {
debugPrint(value['email']);
}
});
DSession.removeUser();
2. Token #
final data = {
'token': 'askuaysuabs',
'expire': '2023-10-10 01:01:01',
};
DSession.setToken(data);
DSession.getToken().then((value) {
debugPrint(value.toString());
});
DSession.removeToken();
3. Custom #
For custom, you must set the key. The keyword must be other than:
- d_session_user
- d_session_token
DSession.setCustom('isDark', true);
final data = await DSession.getCustom('isDark');
debugPrint(data.toString());
bool isDark = data ?? false;
if(isDark){
debugPrint('Dark theme activated');
}
DSession.removeCustom('isDark');
Additional information #
...