Auth<K extends AuthKeys> class
Create an authorized model class for User:
class UserKeys extends AuthKeys {
final address = "address";
final contact = "contact";
const UserKeys._();
static UserKeys? _i;
static UserKeys get i => _i ??= const UserKeys._();
}
class UserModel extends Auth<UserKeys> {
final Address? _address;
final Contact? _contact;
Address get address => _address ?? Address();
Contact get contact => _contact ?? Contact();
UserModel({
super.id,
super.timeMills,
super.accessToken,
super.age,
super.anonymous,
super.biometric,
super.email,
super.extra,
super.gender,
super.idToken,
super.loggedIn,
super.loggedInTime,
super.loggedOutTime,
super.name,
super.online,
super.password,
super.path,
super.phone,
super.photo,
super.platform,
super.provider,
super.random,
super.token,
super.username,
super.verified,
Address? address,
Contact? contact,
}) : _address = address,
_contact = contact;
factory UserModel.from(Object? source) {
if (source is UserModel) return source;
final key = UserKeys.i;
final root = Auth.from(source);
return UserModel(
// ROOT PROPERTIES
id: root.idOrNull,
timeMills: root.timeMillsOrNull,
accessToken: root.accessToken,
age: root.age,
anonymous: root.anonymous,
biometric: root.biometric,
email: root.email,
extra: root.extra,
gender: root.gender,
idToken: root.idToken,
loggedIn: root.loggedIn,
loggedInTime: root.loggedInTime,
loggedOutTime: root.loggedOutTime,
name: root.name,
online: root.online,
password: root.password,
path: root.path,
phone: root.phone,
photo: root.photo,
platform: root.platform,
provider: root.provider,
random: root.random,
token: root.token,
username: root.username,
verified: root.verified,
// CHILD PROPERTIES
address: source.entityValue(key.address, Address.from),
contact: source.entityValue(key.contact, Contact.from),
);
}
UserModel copy({
String? id,
int? timeMills,
String? accessToken,
int? age,
bool? anonymous,
bool? biometric,
String? email,
Map<String, dynamic>? extra,
String? gender,
String? idToken,
bool? loggedIn,
int? loggedInTime,
int? loggedOutTime,
String? name,
int? online,
String? password,
String? path,
String? phone,
String? photo,
String? platform,
Provider? provider,
double? random,
String? token,
String? username,
bool? verified,
}) {
return UserModel(
id: id ?? idOrNull,
timeMills: timeMills ?? timeMillsOrNull,
accessToken: accessToken ?? this.accessToken,
age: age ?? this.age,
anonymous: anonymous ?? this.anonymous,
biometric: biometric ?? this.biometric,
email: email ?? this.email,
extra: extra ?? this.extra,
gender: gender ?? this.gender,
idToken: idToken ?? this.idToken,
loggedIn: loggedIn ?? this.loggedIn,
loggedInTime: loggedInTime ?? this.loggedInTime,
loggedOutTime: loggedOutTime ?? this.loggedOutTime,
name: name ?? this.name,
online: online ?? this.online,
password: password ?? this.password,
path: path ?? this.path,
phone: phone ?? this.phone,
photo: photo ?? this.photo,
platform: platform ?? this.platform,
provider: provider ?? this.provider,
random: random ?? this.random,
token: token ?? this.token,
username: username ?? this.username,
verified: verified ?? this.verified,
);
}
@override
UserModel update({
Modifier<String>? id,
Modifier<int>? timeMills,
Modifier<String>? accessToken,
Modifier<int>? age,
Modifier<bool>? anonymous,
Modifier<bool>? biometric,
Modifier<String>? email,
Modifier<Map<String, dynamic>>? extra,
Modifier<String>? gender,
Modifier<String>? idToken,
Modifier<bool>? loggedIn,
Modifier<int>? loggedInTime,
Modifier<int>? loggedOutTime,
Modifier<String>? name,
Modifier<int>? online,
Modifier<String>? password,
Modifier<String>? path,
Modifier<String>? phone,
Modifier<String>? photo,
Modifier<String>? platform,
Modifier<Provider>? provider,
Modifier<double>? random,
Modifier<String>? token,
Modifier<String>? username,
Modifier<bool>? verified,
Modifier<Address>? address,
Modifier<Contact>? contact,
}) {
return UserModel(
id: modify(id, idOrNull),
timeMills: modify(timeMills, timeMillsOrNull),
accessToken: modify(accessToken, this.accessToken),
age: modify(age, this.age),
anonymous: modify(anonymous, this.anonymous),
biometric: modify(biometric, this.biometric),
email: modify(email, this.email),
extra: modify(extra, this.extra),
gender: modify(gender, this.gender),
idToken: modify(idToken, this.idToken),
loggedIn: modify(loggedIn, this.loggedIn),
loggedInTime: modify(loggedInTime, this.loggedInTime),
loggedOutTime: modify(loggedOutTime, this.loggedOutTime),
name: modify(name, this.name),
online: modify(online, this.online),
password: modify(password, this.password),
path: modify(path, this.path),
phone: modify(phone, this.phone),
photo: modify(photo, this.photo),
platform: modify(platform, this.platform),
provider: modify(provider, this.provider),
random: modify(random, this.random),
token: modify(token, this.token),
username: modify(username, this.username),
verified: modify(verified, this.verified),
address: modify(address, _address),
contact: modify(contact, _contact),
);
}
@override
UserKeys makeKey() => UserKeys.i;
@override
Iterable<Object?> get props {
return [
...super.props,
_address,
_contact,
];
}
@override
Map<String, dynamic> get source {
return {
...super.source,
key.address: _address?.source,
key.contact: _contact?.source,
};
}
@override
String toString() => "$UserModel#$hashCode($json)";
}
class Address extends Entity {
Address();
factory Address.from(Object? source) {
return Address();
}
}
class Contact extends Entity {
Contact();
factory Contact.from(Object? source) {
return Contact();
}
}
- Implementers
Constructors
-
Auth({String? id = "", int? timeMills, String? accessToken, int? age, bool? anonymous, bool? biometric, String? email, Map<
String, dynamic> ? extra, String? gender, String? idToken, bool? loggedIn, int? loggedInTime, int? loggedOutTime, String? name, int? online, String? password, String? path, String? phone, String? photo, String? platform, Provider? provider, double? random, String? token, String? username, bool? verified}) - Auth.from(Object? source)
-
factory
Properties
- accessToken → String?
-
final
- age → int?
-
final
- anonymous → bool?
-
final
- biometric → bool?
-
final
- dateTime → DateTime
-
The timestamp as a DateTime object
no setterinherited
- dateTimeOrNull → DateTime?
-
The timestamp as a DateTime object, or null if invalid
no setterinherited
- email → String?
-
final
-
extra
→ Map<
String, dynamic> ? -
final
-
filtered
→ Map<
String, dynamic> -
Returns the entity as a map with only insertable fields
no setterinherited
- filteredJson → String
-
Returns the filtered entity as a JSON string
no setterinherited
- gender → String?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → String
-
The unique identifier of the entity as a string
no setterinherited
- idInt → int
-
The unique identifier of the entity as an integer
no setterinherited
- idOrNull → String?
-
finalinherited
- idToken → String?
-
final
-
ignoredKeys
→ Iterable<
String> -
Returns keys that are ignored (not insertable)
no setterinherited
- isAnonymous → bool
-
no setter
- isAuthenticated → bool
-
no setter
- isBiometric → bool
-
no setter
- isLoggedIn → bool
-
no setter
- isOnline → bool
-
no setter
- isVerified → bool
-
no setter
- json → String
-
Returns the entity as a JSON string
no setter
- key → K
-
The key associated with the entity
no setterinherited
- lastLoggedInDate → DateTime
-
no setter
- lastLoggedInTime → Duration
-
no setter
- lastLoggedOutDate → DateTime
-
no setter
- lastLoggedOutTime → Duration
-
no setter
- lastOnline → DateTime?
-
no setter
- lastOnlineInDuration → Duration
-
no setter
- loggedIn → bool?
-
final
- loggedInTime → int?
-
final
- loggedOutTime → int?
-
final
- name → String?
-
final
- online → int?
-
final
- password → String?
-
final
- path → String?
-
final
- phone → String?
-
final
- photo → String?
-
final
- platform → String?
-
final
-
props
→ Iterable<
Object?> -
no setter
- provider → Provider?
-
final
- random → double?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
source
→ Map<
String, dynamic> -
Returns the entity as a map with all fields
no setter
- timeMills → int
-
The timestamp in milliseconds since epoch
no setterinherited
- timeMillsOrNull → int?
-
finalinherited
- token → String?
-
final
- username → String?
-
final
- verified → bool?
-
final
Methods
-
copy(
{String? id, int? timeMills, String? accessToken, int? age, bool? anonymous, bool? biometric, String? email, Map< String, dynamic> ? extra, String? gender, String? idToken, bool? loggedIn, int? loggedInTime, int? loggedOutTime, String? name, int? online, String? password, String? path, String? phone, String? photo, String? platform, Provider? provider, double? random, String? token, String? username, bool? verified}) → Auth<AuthKeys> -
equals(
Object? e1, Object? e2) → bool -
Compare two elements for being equal.
inherited
-
hash(
Object? o) → int -
Creates a combined hash code for a number of objects.
inherited
-
isInsertable(
String key, dynamic value) → bool -
Checks if a field is insertable (valid key and non-null value)
inherited
-
isValidKey(
Object? o) → bool -
Test whether an object is a valid argument to equals and hash.
inherited
-
iterableEquals<
T> (Iterable< T> a, Iterable<T> b, {bool unordered = false, bool equals(T a, T b)?}) → bool -
inherited
-
makeKey(
) → K - Constructs the key for the entity.
-
modify<
T extends Object> (Modifier< T> ? current, T? old) → T? -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notEquals(
dynamic e1, dynamic e2) → bool -
Compare two elements for being not equal.
inherited
-
toString(
) → String - A string representation of this object.
-
update(
{Modifier< String> ? id, Modifier<int> ? timeMills, Modifier<String> ? accessToken, Modifier<int> ? age, Modifier<bool> ? anonymous, Modifier<bool> ? biometric, Modifier<String> ? email, Modifier<Map< ? extra, Modifier<String, dynamic> >String> ? gender, Modifier<String> ? idToken, Modifier<bool> ? loggedIn, Modifier<int> ? loggedInTime, Modifier<int> ? loggedOutTime, Modifier<String> ? name, Modifier<int> ? online, Modifier<String> ? password, Modifier<String> ? path, Modifier<String> ? phone, Modifier<String> ? photo, Modifier<String> ? platform, Modifier<Provider> ? provider, Modifier<double> ? random, Modifier<String> ? token, Modifier<String> ? username, Modifier<bool> ? verified}) → Auth<AuthKeys>
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited