- I am trying to store username, email and ID
It seems ID is being stored but username and email aren’t, they seem to be overridden with the ID?!
Here is my UserSecureStorage class of getters and setters
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
class UserSecureStorage {
static final _storage = FlutterSecureStorage();
static const _keyUsername = '';
static const _keyUserId = '';
static const _keyUserEmail = '';
// get set profilename
static Future setProfileName(String profileName) async =>
await _storage.write(key: _keyUsername, value: profileName);
static Future<String> getProfileName() async =>
await _storage.read(key: _keyUsername);
// get set profileemail
static Future setProfileEmail(String profileEmail) async =>
await _storage.write(key: _keyUserEmail, value: profileEmail);
static Future<String> getProfileEmail() async =>
await _storage.read(key: _keyUserEmail);
// get set profileid
static Future setProfileId(String profileId) async =>
await _storage.write(key: _keyUserId, value: profileId);
static Future<String> getProfileId() async =>
await _storage.read(key: _keyUserId);
}
here is where I am getting the profile details form the API and then attempting to set, Username, email, ID
apiService
.loadProfile()
.then((profile) async {
await UserSecureStorage
.setProfileName(profile.name);
await UserSecureStorage.setProfileEmail(
profile.email);
await UserSecureStorage.setProfileId(
profile.id);
});
here is where I am getting them:
Future init() async {
final profilename = await UserSecureStorage.getProfileName() ?? '';
final profileemail = await UserSecureStorage.getProfileEmail() ?? '';
final profileid = await UserSecureStorage.getProfileId() ?? '';
setState(() {
profileName = profilename;
profileEmail = profileemail;
profileId = profileid;
});
}
and a bit further down:
new UserAccountsDrawerHeader(
accountName: new Text('$profileName'),
accountEmail: new Text('$profileEmail'),.......
as you can see, I am not even trying to output ID and they both equal 2 (the ID of the person logged in)