User class final
Core application user model.
A User represents an authenticated or auth-capable account within the
framework. It stores identity fields, an optional hashed password, and
exposes convenience helpers for loading attached roles.
Example:
final user = User(
name: 'Jane Doe',
email: 'jane@example.com',
password: 'secret123',
);
print(user.email); // jane@example.com
- Inheritance
- Mixed-in types
- Available extensions
Constructors
Properties
- createdAt ↔ DateTime?
-
Creation timestamp (UTC).
getter/setter pairinherited
- disk ↔ DatabaseDisk
-
getter/setter pairinherited
- email ↔ String
-
User email address.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- id ↔ int?
-
Primary key (auto-incremented by backend).
getter/setter pairinherited
- name ↔ String
-
User display name.
getter/setter pair
- password ↔ String?
-
Hashed password value, when present.
getter/setter pair
-
roles
→ Future<
List< Role> > -
Resolves all roles attached to this user through the user/role pivot
table.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- updatedAt ↔ DateTime?
-
Last update timestamp (UTC).
getter/setter pairinherited
- uuid ↔ String?
-
UUID for cross-backend identification.
getter/setter pairinherited
Methods
-
attach(
Model sibling, {required ModelRelationshipType relationship, PivotTable< Model, Model> ? table, DatabaseDisk disk = Model.defaultDisk}) → Future<bool> -
Available on Model, provided by the ModelRelationshipOps extension
Attachessiblingto this model using the givenrelationshiptype. -
attachRole(
RoleType role, {DatabaseDisk disk = Model.defaultDisk}) → Future< bool> -
Available on User, provided by the HasRole extension
Attaches the givenroleto the user. -
belongsToMany<
T extends Model> ({required PivotTable< Model, Model> table, DatabaseDisk disk = Model.defaultDisk}) → Future<List< T> > -
Available on Model, provided by the ModelRelationships extension
Resolves many-to-many related models through a pivot table. -
belongsToOne<
T extends Model> ({DatabaseDisk disk = Model.defaultDisk}) → Future< T?> -
Available on Model, provided by the ModelRelationships extension
Resolves the parent model for an inverse relationship. -
delete(
{DatabaseDisk? disk}) → Future< bool> -
Deletes the current instance.
inherited
-
detach(
Model sibling, {required ModelRelationshipType relationship, PivotTable< Model, Model> ? table, DatabaseDisk disk = Model.defaultDisk}) → Future<bool> -
Available on Model, provided by the ModelRelationshipOps extension
Detachessiblingfrom this model using the givenrelationshiptype. -
detachRole(
RoleType role, {DatabaseDisk disk = Model.defaultDisk}) → Future< bool> -
Available on User, provided by the HasRole extension
Detaches the givenrolefrom the user. -
getInstanceTableName(
) → String -
inherited
-
getInstanceTableSingularName(
) → String -
inherited
-
hasMany<
T extends Model> ({DatabaseDisk disk = Model.defaultDisk}) → Future< List< T> > -
Available on Model, provided by the ModelRelationships extension
Resolves all one-to-many related models. -
hasOne<
T extends Model> ({DatabaseDisk disk = Model.defaultDisk}) → Future< T?> -
Available on Model, provided by the ModelRelationships extension
Resolves a one-to-one related model. -
hasRole(
RoleType role) → Future< bool> -
Available on User, provided by the HasRole extension
Returnstruewhen the user currently has the givenrole. -
load<
T extends Model> (ModelRelationshipType relationship, {PivotTable< Model, Model> ? table}) → Future<Map< String, dynamic> > -
Available on Model, provided by the ModelRelationshipOps extension
Loads a relationship and returns this model serialized with the related data embedded. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
save(
{DatabaseDisk? disk}) → Future< bool> -
Saves the current instance.
inherited
-
toJson(
) → Map< String, dynamic> -
Serializes the user into its standard JSON representation.
override
-
toMetaJson(
) → Map< String, dynamic> -
Serializes the user into a metadata-oriented JSON map.
override
-
toString(
) → String -
Human-readable string representation.
inherited
-
update(
{required Map< String, dynamic> withJson, DatabaseDisk? disk}) → Future<bool> -
Updates the current instance with new data.
inherited
-
withRoles(
) → Future< Map< String, dynamic> > - Returns this user serialized with resolved role data.
-
withRoles(
) → Future< Map< String, dynamic> > - Returns this user serialized with resolved role data.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
-
columnDefinitions
↔ Map<
String, String> -
Database column definitions for persisted users.
getter/setter pair