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

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, Provider? provider})
Auth.from(Object? source)
factory

Properties

accessToken → String?
final
biometric → BiometricStatus
no setter
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
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
isAuthenticated → bool
no setter
isBiometric → bool
no setter
isLoggedIn → bool
no setter
isVerified → bool
no setter
json → String
Returns the entity as a JSON string
no setteroverride
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
props → Iterable<Object?>
no setterinherited
provider → Provider?
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 with all fields
no setteroverride
timeMills → int
The timestamp in milliseconds since epoch
no setterinherited
timeMillsOrNull → int?
finalinherited
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, Provider? provider, 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() → Key
Constructs the key for the entity.
override
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.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited