Line data Source code
1 : part of apptive_grid_model; 2 : 3 : /// Model for a User 4 : class User { 5 : /// Creates a new Space Model with a certain [id], [firstName], [lastName] and [email] 6 : /// [spaces] is [List<SpaceUri>] pointing to the [Spaces]s of this [User] 7 1 : User({ 8 : required this.email, 9 : required this.lastName, 10 : required this.firstName, 11 : required this.id, 12 : required this.spaces, 13 : }); 14 : 15 : /// Deserializes [json] into a [User] Object 16 2 : User.fromJson(Map<String, dynamic> json) 17 2 : : email = json['email'], 18 2 : lastName = json['lastName'], 19 2 : firstName = json['firstName'], 20 2 : id = json['id'], 21 2 : spaces = (json['spaceUris'] as List) 22 6 : .map((e) => SpaceUri.fromUri(e)) 23 2 : .toList(); 24 : 25 : /// Email of the this [User] 26 : final String email; 27 : 28 : /// Last Name of this [User] 29 : final String lastName; 30 : 31 : /// First Name of this [User] 32 : final String firstName; 33 : 34 : /// Id of this [User] 35 : final String id; 36 : 37 : /// [SpaceUri]s pointing to [Space]s created by this [User] 38 : final List<SpaceUri> spaces; 39 : 40 : /// Serializes this [Space] into a json Map 41 2 : Map<String, dynamic> toJson() => { 42 1 : 'email': email, 43 1 : 'lastName': lastName, 44 1 : 'firstName': firstName, 45 1 : 'id': id, 46 5 : 'spaceUris': spaces.map((e) => e.uriString).toList(), 47 : }; 48 : 49 1 : @override 50 : String toString() { 51 7 : return 'User(email: $email, lastName: $lastName, firstName: $firstName, id: $id, spaces: ${spaces.toString()})'; 52 : } 53 : 54 1 : @override 55 : bool operator ==(Object other) { 56 1 : return other is User && 57 3 : id == other.id && 58 3 : email == other.email && 59 3 : lastName == other.lastName && 60 3 : firstName == other.firstName && 61 3 : f.listEquals(spaces, other.spaces); 62 : } 63 : 64 1 : @override 65 2 : int get hashCode => toString().hashCode; 66 : }