fetchUserAttributes method

Future<List<AuthUserAttribute>> fetchUserAttributes({
  1. FetchUserAttributesOptions? options,
})

Fetch all user attributes associated with the current user.

Optionally accepts plugin options which allow customizing provider-specific behavior, e.g. the Cognito User Pool.

For more information, see the Amplify docs.

Examples

import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_flutter/amplify_flutter.dart';
Future<void> fetchCurrentUserAttributes() async {
  try {
    final result = await Amplify.Auth.fetchUserAttributes();
    for (final element in result) {
      safePrint('key: ${element.userAttributeKey}; value: ${element.value}');
    }
  } on AuthException catch (e) {
    safePrint('Error fetching user attributes: ${e.message}');
  }
}

Implementation

Future<List<AuthUserAttribute>> fetchUserAttributes({
  FetchUserAttributesOptions? options,
}) =>
    identifyCall(
      AuthCategoryMethod.fetchUserAttributes,
      () => defaultPlugin.fetchUserAttributes(options: options),
    );