User class

Represents a user in the Better Auth system.

The User class contains all user-related information returned by the Better Auth API, including identity, profile data, and metadata.

Example:

final user = User.fromJson(jsonResponse);
print('User: ${user.name} (${user.email})');

See also:

  • Session for authentication session information

Constructors

User({required String id, required String email, String? name, String? image, bool emailVerified = false, String? role, required DateTime createdAt, required DateTime updatedAt, Map<String, dynamic>? metadata})
Creates a new User instance.
User.fromJson(Map<String, dynamic> json)
Creates a User instance from a JSON response.
factory

Properties

createdAt DateTime
Timestamp when the user account was created.
final
email String
User's email address.
final
emailVerified bool
Whether the email has been verified.
final
hashCode int
The hash code for this object.
no setteroverride
id String
Unique user identifier.
final
image String?
User's profile image URL.
final
metadata Map<String, dynamic>?
Custom metadata associated with the user.
final
name String?
User's display name.
final
role String?
User's role in the system.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
updatedAt DateTime
Timestamp when the user account was last updated.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this User to a JSON map.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
override