Session class
Represents an authentication session.
A Session contains information about an authenticated user session, including the associated user, token, and expiration time.
Example:
final session = Session.fromJson(response.data);
print('Session expires: ${session.expiresAt}');
print('User: ${session.user.email}');
See also:
- User for user information within a session
- BetterAuthClient for session management methods
Constructors
- Session({required String id, required User user, required String token, required DateTime expiresAt, String? ipAddress, String? userAgent, bool isCurrent = false, required DateTime createdAt})
- Creates a new Session instance.
-
Session.fromJson(Map<
String, dynamic> json) -
Creates a Session instance from a JSON response.
factory
Properties
- createdAt → DateTime
-
Timestamp when the session was created.
final
- expiresAt → DateTime
-
When the session expires.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- id → String
-
Unique session identifier.
final
- ipAddress → String?
-
IP address from which the session was created.
final
- isCurrent → bool
-
Whether this session is from the current device.
final
- isExpired → bool
-
Whether this session has expired.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- token → String
-
The session token.
final
- user → User
-
The user associated with this session.
final
- userAgent → String?
-
User agent of the device that created the session.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts this Session to a JSON map.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override