getUser function

Future<Map<String, dynamic>> getUser()

Retrieves the user information from storage.

Throws an exception if the user is not defined. Returns the user information if it exists.

Throws:

  • Exception: If the user is not defined.

Returns:

  • The user information. Example usage:
final user = await getUser();
print(user['userId']);
print(user['sessionId']);

Implementation

Future<Map<String, dynamic>> getUser() async {
  final user = await getStorageItem(key: 'sgm_user');

  if (user == null) {
    throw Exception('Error: User is not defined.');
  }

  return user;
}