exec method

Future<String> exec()

現在ログインしているユーザーのメールアドレスを取得する

Implementation

Future<String> exec() async {
  try {
    final attributes = await _amplifyClass.Auth.fetchUserAttributes();

    final emailAttribute = attributes.firstWhere((attribute) =>
        attribute.userAttributeKey == AuthUserAttributeKey.email);
    return emailAttribute.value;
  } catch (e) {
    throw ServiceException(
      ServiceErrorType.authError,
      ServiceErrorType.authError.message,
    );
  }
}