Auth<Key extends AuthKeys> class
Create an authorized model class for User:
class AuthKeys extends AuthKeys {
final address = "address";
final contact = "contact";
const AuthKeys._();
static AuthKeys? _i;
static AuthKeys get i => _i ??= const AuthKeys._();
}
class UserModel extends Auth<AuthKeys> {
final Address? _address;
final Contact? _contact;
Address get address => _address ?? Address();
Contact get contact => _contact ?? Contact();
UserModel({
super.id,
super.timeMills,
super.accessToken,
super.biometric,
super.email,
super.extra,
super.idToken,
super.loggedIn,
super.name,
super.password,
super.phone,
super.photo,
super.provider,
super.username,
Address? address,
Contact? contact,
}) : _address = address,
_contact = contact;
factory UserModel.from(Object? source) {
final key = AuthKeys.i;
final root = Auth.from(source);
return UserModel(
// ROOT PROPERTIES
id: root.id,
timeMills: root.timeMills,
accessToken: root.accessToken,
biometric: root.biometric,
email: root.email,
extra: root.extra,
idToken: root.idToken,
loggedIn: root.loggedIn,
name: root.name,
password: root.password,
phone: root.phone,
photo: root.photo,
provider: root.provider,
username: root.username,
// CHILD PROPERTIES
address: source.entityObject(key.address, Address.from),
contact: source.entityObject(key.address, Contact.from),
);
}
@override
UserModel copy({
String? id,
int? timeMills,
String? accessToken,
String? biometric,
String? email,
Map<String, dynamic>? extra,
String? idToken,
bool? loggedIn,
String? name,
String? password,
String? phone,
String? photo,
String? provider,
String? username,
Address? address,
Contact? contact,
}) {
return UserModel(
id: id ?? this.id,
timeMills: timeMills ?? this.timeMills,
accessToken: accessToken ?? this.accessToken,
biometric: biometric ?? this.biometric,
email: email ?? this.email,
extra: extra ?? this.extra,
idToken: idToken ?? this.idToken,
loggedIn: loggedIn ?? this.loggedIn,
name: name ?? this.name,
password: password ?? this.password,
phone: phone ?? this.phone,
photo: photo ?? this.photo,
provider: provider ?? this.provider,
username: username ?? this.username,
address: address ?? this.address,
contact: contact ?? this.contact,
);
}
@override
AuthKeys makeKey() => AuthKeys.i;
@override
Map<String, dynamic> get source {
return super.source.attach({
key.address: _address?.source,
key.contact: _contact?.source,
});
}
}
class Address extends Entity {
Address();
factory Address.from(Object? source) {
return Address();
}
}
class Contact extends Entity {
Contact();
factory Contact.from(Object? source) {
return Contact();
}
}
- Inheritance
- Implementers
Constructors
-
Auth({String? id = "", int? timeMills, String? accessToken, String? email, Map<
String, dynamic> ? extra, String? idToken, bool? loggedIn, int? loggedInTime, int? loggedOutTime, String? name, String? password, String? phone, String? photo, String? username, bool? verified, BiometricStatus? biometric, AuthProviders? provider}) - Auth.from(Object? source)
-
factory
- Auth.fromUser(User? user)
-
factory
Properties
- accessToken → String?
-
final
- biometric → BiometricStatus
-
no setter
- email → String?
-
final
-
extra
→ Map<
String, dynamic> ? -
final
-
filtered
→ Map<
String, dynamic> -
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
no setterinherited
- idInt → int
-
The unique identifier of the entity as an integer.
no setterinherited
- idOrNull ↔ String?
-
getter/setter pairinherited
- idToken → String?
-
final
-
ignoredKeys
→ Iterable<
String> -
no setterinherited
- isBiometric → bool
-
no setter
- isCurrentUid → bool
-
no setter
- isLoggedIn → bool
-
no setter
- isVerified → bool
-
no setter
- key → Key
-
The key associated with the entity.
no setterinherited
- lastLoggedInDate → DateTime
-
no setter
- lastLoggedInTime → Duration
-
no setter
- lastLoggedOutDate → DateTime
-
no setter
- lastLoggedOutTime → Duration
-
no setter
- loggedIn → bool?
-
final
- loggedInTime → int?
-
final
- loggedOutTime → int?
-
final
- name → String?
-
final
- password → String?
-
final
- phone → String?
-
final
- photo → String?
-
final
- provider → AuthProviders
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
source
→ Map<
String, dynamic> -
Returns the entity as a map.
no setteroverride
- timeMills → int
-
no setterinherited
- timeMillsOrNull ↔ int?
-
getter/setter pairinherited
- username → String?
-
final
- verified → bool?
-
final
Methods
-
copy(
{String? id, int? timeMills, String? accessToken, BiometricStatus? biometric, String? email, Map< String, dynamic> ? extra, String? idToken, bool? loggedIn, int? loggedInTime, int? loggedOutTime, String? name, String? password, String? phone, String? photo, AuthProviders? provider, String? username, bool? verified}) → Auth<AuthKeys> -
isInsertable(
String key, dynamic value) → bool -
override
-
makeKey(
) → Key -
Constructs the key for the entity.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
Returns a string representation of the source map.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited