Auth<Key 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.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 = UserKeys.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
  UserKeys makeKey() => UserKeys.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? biometric, String? email, Map<String, dynamic>? extra, String? idToken, bool? loggedIn, int? loggedInTime, int? loggedOutTime, String? name, String? password, String? phone, String? photo, String? provider, String? username, bool? verified})
Auth.from(Object? source)
factory
Auth.fromUser(User? user)
factory

Properties

accessToken String?
final
biometric String?
final
email String?
final
extra Map<String, dynamic>?
final
hashCode int
The hash code for this object.
no setterinherited
id String
The unique identifier of the entity.
getter/setter pairinherited
idInt int
The unique identifier of the entity as an integer.
no setterinherited
idToken String?
final
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
mBiometric BiometricStatus
no setter
mProvider AuthProviders
no setter
name String?
final
password String?
final
phone String?
final
photo String?
final
provider String?
final
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
The timestamp associated with the entity.
getter/setter pairinherited
username String?
final
verified bool?
final

Methods

copy({String? id, int? timeMills, String? accessToken, String? biometric, String? email, Map<String, dynamic>? extra, String? idToken, bool? loggedIn, int? loggedInTime, int? loggedOutTime, String? name, String? password, String? phone, String? photo, String? 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