ExtendableUser class abstract
A base class that allows you to extend the User model with custom properties
Example of how to extend this class:
class CustomUser extends ExtendableUser {
final String customField;
CustomUser({
required super.id,
required super.email,
required super.name,
super.image,
required super.createdAt,
required super.updatedAt,
super.emailVerified,
super.twoFactorEnabled,
super.username,
super.displayUsername,
super.isAnonymous,
super.phoneNumber,
super.phoneNumberVerified,
required this.customField,
});
factory CustomUser.fromJson(Map<String, dynamic> json) {
return CustomUser(
id: json['id'],
email: json['email'],
name: json['name'],
image: json['image'],
createdAt: DateTime.parse(json['createdAt']),
updatedAt: DateTime.parse(json['updatedAt']),
emailVerified: json['emailVerified'],
twoFactorEnabled: json['twoFactorEnabled'],
username: json['username'],
displayUsername: json['displayUsername'],
isAnonymous: json['isAnonymous'],
phoneNumber: json['phoneNumber'],
phoneNumberVerified: json['phoneNumberVerified'],
customField: json['customField'],
);
}
@override
Map<String, dynamic> toJson() {
final json = super.toJson();
json['customField'] = customField;
return json;
}
}
Constructors
-
ExtendableUser.new({required String id, required String email, required String name, String? image, required DateTime createdAt, required DateTime updatedAt, bool? emailVerified, bool? twoFactorEnabled, String? username, String? displayUsername, bool? isAnonymous, String? phoneNumber, bool? phoneNumberVerified, DateTime? banExpires, String? banReason, bool? banned, Map<
String, dynamic> ? customProperties, String? role})
Properties
- banExpires → DateTime?
-
finalinherited
- banned → bool?
-
finalinherited
- banReason → String?
-
finalinherited
- createdAt → DateTime
-
finalinherited
-
customProperties
→ Map<
String, dynamic> ? -
Custom properties that don't fit in the standard model
finalinherited
- displayUsername → String?
-
finalinherited
- email → String
-
finalinherited
- emailVerified → bool?
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
finalinherited
- image → String?
-
finalinherited
- isAnonymous → bool?
-
finalinherited
- name → String
-
finalinherited
- phoneNumber → String?
-
finalinherited
- phoneNumberVerified → bool?
-
finalinherited
- role → String?
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- twoFactorEnabled → bool?
-
finalinherited
- updatedAt → DateTime
-
finalinherited
- username → String?
-
finalinherited
Methods
-
getCustomProperty<
T> (String key) → T? -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> -
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited