d_session 0.0.2 copy "d_session: ^0.0.2" to clipboard
d_session: ^0.0.2 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
  2. Token
  3. Custom

1. User #

Map user = {
'id': 'aha276avsUHUa',
'email': '[email protected]',
'username': 'indre',
};
DSession.setUser(user);

DSession.getUser().then((value) {
    debugPrint(value.toString());
    if (value != null) {
        debugPrint(value['email']);
    }
});

DSession.removeUser();

2. Token #

Map 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 #

...

0
likes
130
pub points
35%
popularity

Publisher

verified publisherindratrisnar.com

Easy way to access Shared Preference and use as Session.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, shared_preferences

More

Packages that depend on d_session