getCustomClaim<T> method

T? getCustomClaim<T>(
  1. String key, {
  2. T? defaultValue,
})

Returns a specific custom claim by key.

Parameters:

  • key - The claim key to retrieve
  • defaultValue - The default value to return if the claim doesn't exist

Returns the claim value if found, otherwise returns defaultValue.

Implementation

T? getCustomClaim<T>(String key, {T? defaultValue}) {
  final claims = getCustomClaims();
  if (claims == null) return defaultValue;
  final value = claims[key];
  if (value is T) return value;
  return defaultValue;
}