Refactor mobile to use OpenApi generated SDK (#336)

This commit is contained in:
Alex 2022-07-13 07:23:48 -05:00 committed by GitHub
parent d69470e207
commit ae7e582ec8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
276 changed files with 14513 additions and 3003 deletions

View file

@ -1,100 +0,0 @@
import 'dart:convert';
class DeviceInfoRemote {
final int id;
final String userId;
final String deviceId;
final String deviceType;
final String notificationToken;
final String createdAt;
final bool isAutoBackup;
DeviceInfoRemote({
required this.id,
required this.userId,
required this.deviceId,
required this.deviceType,
required this.notificationToken,
required this.createdAt,
required this.isAutoBackup,
});
DeviceInfoRemote copyWith({
int? id,
String? userId,
String? deviceId,
String? deviceType,
String? notificationToken,
String? createdAt,
bool? isAutoBackup,
}) {
return DeviceInfoRemote(
id: id ?? this.id,
userId: userId ?? this.userId,
deviceId: deviceId ?? this.deviceId,
deviceType: deviceType ?? this.deviceType,
notificationToken: notificationToken ?? this.notificationToken,
createdAt: createdAt ?? this.createdAt,
isAutoBackup: isAutoBackup ?? this.isAutoBackup,
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'userId': userId,
'deviceId': deviceId,
'deviceType': deviceType,
'notificationToken': notificationToken,
'createdAt': createdAt,
'isAutoBackup': isAutoBackup,
};
}
factory DeviceInfoRemote.fromMap(Map<String, dynamic> map) {
return DeviceInfoRemote(
id: map['id']?.toInt() ?? 0,
userId: map['userId'] ?? '',
deviceId: map['deviceId'] ?? '',
deviceType: map['deviceType'] ?? '',
notificationToken: map['notificationToken'] ?? '',
createdAt: map['createdAt'] ?? '',
isAutoBackup: map['isAutoBackup'] ?? false,
);
}
String toJson() => json.encode(toMap());
factory DeviceInfoRemote.fromJson(String source) =>
DeviceInfoRemote.fromMap(json.decode(source));
@override
String toString() {
return 'DeviceInfo(id: $id, userId: $userId, deviceId: $deviceId, deviceType: $deviceType, notificationToken: $notificationToken, createdAt: $createdAt, isAutoBackup: $isAutoBackup)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is DeviceInfoRemote &&
other.id == id &&
other.userId == userId &&
other.deviceId == deviceId &&
other.deviceType == deviceType &&
other.notificationToken == notificationToken &&
other.createdAt == createdAt &&
other.isAutoBackup == isAutoBackup;
}
@override
int get hashCode {
return id.hashCode ^
userId.hashCode ^
deviceId.hashCode ^
deviceType.hashCode ^
notificationToken.hashCode ^
createdAt.hashCode ^
isAutoBackup.hashCode;
}
}

View file

@ -1,212 +0,0 @@
import 'dart:convert';
class ImmichExif {
final int? id;
final String? assetId;
final String? make;
final String? model;
final String? imageName;
final int? exifImageWidth;
final int? exifImageHeight;
final int? fileSizeInByte;
final String? orientation;
final String? dateTimeOriginal;
final String? modifyDate;
final String? lensModel;
final double? fNumber;
final double? focalLength;
final int? iso;
final double? exposureTime;
final double? latitude;
final double? longitude;
final String? city;
final String? state;
final String? country;
ImmichExif({
this.id,
this.assetId,
this.make,
this.model,
this.imageName,
this.exifImageWidth,
this.exifImageHeight,
this.fileSizeInByte,
this.orientation,
this.dateTimeOriginal,
this.modifyDate,
this.lensModel,
this.fNumber,
this.focalLength,
this.iso,
this.exposureTime,
this.latitude,
this.longitude,
this.city,
this.state,
this.country,
});
ImmichExif copyWith({
int? id,
String? assetId,
String? make,
String? model,
String? imageName,
int? exifImageWidth,
int? exifImageHeight,
int? fileSizeInByte,
String? orientation,
String? dateTimeOriginal,
String? modifyDate,
String? lensModel,
double? fNumber,
double? focalLength,
int? iso,
double? exposureTime,
double? latitude,
double? longitude,
String? city,
String? state,
String? country,
}) {
return ImmichExif(
id: id ?? this.id,
assetId: assetId ?? this.assetId,
make: make ?? this.make,
model: model ?? this.model,
imageName: imageName ?? this.imageName,
exifImageWidth: exifImageWidth ?? this.exifImageWidth,
exifImageHeight: exifImageHeight ?? this.exifImageHeight,
fileSizeInByte: fileSizeInByte ?? this.fileSizeInByte,
orientation: orientation ?? this.orientation,
dateTimeOriginal: dateTimeOriginal ?? this.dateTimeOriginal,
modifyDate: modifyDate ?? this.modifyDate,
lensModel: lensModel ?? this.lensModel,
fNumber: fNumber ?? this.fNumber,
focalLength: focalLength ?? this.focalLength,
iso: iso ?? this.iso,
exposureTime: exposureTime ?? this.exposureTime,
latitude: latitude ?? this.latitude,
longitude: longitude ?? this.longitude,
city: city ?? this.city,
state: state ?? this.state,
country: country ?? this.country,
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'assetId': assetId,
'make': make,
'model': model,
'imageName': imageName,
'exifImageWidth': exifImageWidth,
'exifImageHeight': exifImageHeight,
'fileSizeInByte': fileSizeInByte,
'orientation': orientation,
'dateTimeOriginal': dateTimeOriginal,
'modifyDate': modifyDate,
'lensModel': lensModel,
'fNumber': fNumber,
'focalLength': focalLength,
'iso': iso,
'exposureTime': exposureTime,
'latitude': latitude,
'longitude': longitude,
'city': city,
'state': state,
'country': country,
};
}
factory ImmichExif.fromMap(Map<String, dynamic> map) {
return ImmichExif(
id: map['id']?.toInt(),
assetId: map['assetId'],
make: map['make'],
model: map['model'],
imageName: map['imageName'],
exifImageWidth: map['exifImageWidth']?.toInt(),
exifImageHeight: map['exifImageHeight']?.toInt(),
fileSizeInByte: map['fileSizeInByte']?.toInt(),
orientation: map['orientation'],
dateTimeOriginal: map['dateTimeOriginal'],
modifyDate: map['modifyDate'],
lensModel: map['lensModel'],
fNumber: map['fNumber']?.toDouble(),
focalLength: map['focalLength']?.toDouble(),
iso: map['iso']?.toInt(),
exposureTime: map['exposureTime']?.toDouble(),
latitude: map['latitude']?.toDouble(),
longitude: map['longitude']?.toDouble(),
city: map['city'],
state: map['state'],
country: map['country'],
);
}
String toJson() => json.encode(toMap());
factory ImmichExif.fromJson(String source) =>
ImmichExif.fromMap(json.decode(source));
@override
String toString() {
return 'ImmichExif(id: $id, assetId: $assetId, make: $make, model: $model, imageName: $imageName, exifImageWidth: $exifImageWidth, exifImageHeight: $exifImageHeight, fileSizeInByte: $fileSizeInByte, orientation: $orientation, dateTimeOriginal: $dateTimeOriginal, modifyDate: $modifyDate, lensModel: $lensModel, fNumber: $fNumber, focalLength: $focalLength, iso: $iso, exposureTime: $exposureTime, latitude: $latitude, longitude: $longitude, city: $city, state: $state, country: $country)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ImmichExif &&
other.id == id &&
other.assetId == assetId &&
other.make == make &&
other.model == model &&
other.imageName == imageName &&
other.exifImageWidth == exifImageWidth &&
other.exifImageHeight == exifImageHeight &&
other.fileSizeInByte == fileSizeInByte &&
other.orientation == orientation &&
other.dateTimeOriginal == dateTimeOriginal &&
other.modifyDate == modifyDate &&
other.lensModel == lensModel &&
other.fNumber == fNumber &&
other.focalLength == focalLength &&
other.iso == iso &&
other.exposureTime == exposureTime &&
other.latitude == latitude &&
other.longitude == longitude &&
other.city == city &&
other.state == state &&
other.country == country;
}
@override
int get hashCode {
return id.hashCode ^
assetId.hashCode ^
make.hashCode ^
model.hashCode ^
imageName.hashCode ^
exifImageWidth.hashCode ^
exifImageHeight.hashCode ^
fileSizeInByte.hashCode ^
orientation.hashCode ^
dateTimeOriginal.hashCode ^
modifyDate.hashCode ^
lensModel.hashCode ^
fNumber.hashCode ^
focalLength.hashCode ^
iso.hashCode ^
exposureTime.hashCode ^
latitude.hashCode ^
longitude.hashCode ^
city.hashCode ^
state.hashCode ^
country.hashCode;
}
}

View file

@ -1,110 +0,0 @@
import 'dart:convert';
import 'package:equatable/equatable.dart';
class ImmichAsset extends Equatable {
final String id;
final String deviceAssetId;
final String userId;
final String deviceId;
final String type;
final String createdAt;
final String modifiedAt;
final bool isFavorite;
final String? duration;
final String originalPath;
final String resizePath;
const ImmichAsset({
required this.id,
required this.deviceAssetId,
required this.userId,
required this.deviceId,
required this.type,
required this.createdAt,
required this.modifiedAt,
required this.isFavorite,
this.duration,
required this.originalPath,
required this.resizePath,
});
ImmichAsset copyWith({
String? id,
String? deviceAssetId,
String? userId,
String? deviceId,
String? type,
String? createdAt,
String? modifiedAt,
bool? isFavorite,
String? duration,
String? originalPath,
String? resizePath,
}) {
return ImmichAsset(
id: id ?? this.id,
deviceAssetId: deviceAssetId ?? this.deviceAssetId,
userId: userId ?? this.userId,
deviceId: deviceId ?? this.deviceId,
type: type ?? this.type,
createdAt: createdAt ?? this.createdAt,
modifiedAt: modifiedAt ?? this.modifiedAt,
isFavorite: isFavorite ?? this.isFavorite,
duration: duration ?? this.duration,
originalPath: originalPath ?? this.originalPath,
resizePath: resizePath ?? this.resizePath,
);
}
Map<String, dynamic> toMap() {
final result = <String, dynamic>{};
result.addAll({'id': id});
result.addAll({'deviceAssetId': deviceAssetId});
result.addAll({'userId': userId});
result.addAll({'deviceId': deviceId});
result.addAll({'type': type});
result.addAll({'createdAt': createdAt});
result.addAll({'modifiedAt': modifiedAt});
result.addAll({'isFavorite': isFavorite});
if (duration != null) {
result.addAll({'duration': duration});
}
result.addAll({'originalPath': originalPath});
result.addAll({'resizePath': resizePath});
return result;
}
factory ImmichAsset.fromMap(Map<String, dynamic> map) {
return ImmichAsset(
id: map['id'] ?? '',
deviceAssetId: map['deviceAssetId'] ?? '',
userId: map['userId'] ?? '',
deviceId: map['deviceId'] ?? '',
type: map['type'] ?? '',
createdAt: map['createdAt'] ?? '',
modifiedAt: map['modifiedAt'] ?? '',
isFavorite: map['isFavorite'] ?? false,
duration: map['duration'],
originalPath: map['originalPath'] ?? '',
resizePath: map['resizePath'] ?? '',
);
}
String toJson() => json.encode(toMap());
factory ImmichAsset.fromJson(String source) =>
ImmichAsset.fromMap(json.decode(source));
@override
String toString() {
return 'ImmichAsset(id: $id, deviceAssetId: $deviceAssetId, userId: $userId, deviceId: $deviceId, type: $type, createdAt: $createdAt, modifiedAt: $modifiedAt, isFavorite: $isFavorite, duration: $duration, originalPath: $originalPath, resizePath: $resizePath)';
}
@override
List<Object> get props {
return [id];
}
}

View file

@ -1,135 +0,0 @@
import 'dart:convert';
import 'package:immich_mobile/shared/models/exif.model.dart';
class ImmichAssetWithExif {
final String id;
final String deviceAssetId;
final String userId;
final String deviceId;
final String type;
final String createdAt;
final String modifiedAt;
final String originalPath;
final bool isFavorite;
final String? duration;
final ImmichExif? exifInfo;
ImmichAssetWithExif({
required this.id,
required this.deviceAssetId,
required this.userId,
required this.deviceId,
required this.type,
required this.createdAt,
required this.modifiedAt,
required this.originalPath,
required this.isFavorite,
this.duration,
this.exifInfo,
});
ImmichAssetWithExif copyWith({
String? id,
String? deviceAssetId,
String? userId,
String? deviceId,
String? type,
String? createdAt,
String? modifiedAt,
String? originalPath,
bool? isFavorite,
String? duration,
ImmichExif? exifInfo,
}) {
return ImmichAssetWithExif(
id: id ?? this.id,
deviceAssetId: deviceAssetId ?? this.deviceAssetId,
userId: userId ?? this.userId,
deviceId: deviceId ?? this.deviceId,
type: type ?? this.type,
createdAt: createdAt ?? this.createdAt,
modifiedAt: modifiedAt ?? this.modifiedAt,
originalPath: originalPath ?? this.originalPath,
isFavorite: isFavorite ?? this.isFavorite,
duration: duration ?? this.duration,
exifInfo: exifInfo ?? this.exifInfo,
);
}
Map<String, dynamic> toMap() {
return {
'id': id,
'deviceAssetId': deviceAssetId,
'userId': userId,
'deviceId': deviceId,
'type': type,
'createdAt': createdAt,
'modifiedAt': modifiedAt,
'originalPath': originalPath,
'isFavorite': isFavorite,
'duration': duration,
'exifInfo': exifInfo?.toMap(),
};
}
factory ImmichAssetWithExif.fromMap(Map<String, dynamic> map) {
return ImmichAssetWithExif(
id: map['id'] ?? '',
deviceAssetId: map['deviceAssetId'] ?? '',
userId: map['userId'] ?? '',
deviceId: map['deviceId'] ?? '',
type: map['type'] ?? '',
createdAt: map['createdAt'] ?? '',
modifiedAt: map['modifiedAt'] ?? '',
originalPath: map['originalPath'] ?? '',
isFavorite: map['isFavorite'] ?? false,
duration: map['duration'],
exifInfo:
map['exifInfo'] != null ? ImmichExif.fromMap(map['exifInfo']) : null,
);
}
String toJson() => json.encode(toMap());
factory ImmichAssetWithExif.fromJson(String source) =>
ImmichAssetWithExif.fromMap(json.decode(source));
@override
String toString() {
return 'ImmichAssetWithExif(id: $id, deviceAssetId: $deviceAssetId, userId: $userId, deviceId: $deviceId, type: $type, createdAt: $createdAt, modifiedAt: $modifiedAt, originalPath: $originalPath, isFavorite: $isFavorite, duration: $duration, exifInfo: $exifInfo)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ImmichAssetWithExif &&
other.id == id &&
other.deviceAssetId == deviceAssetId &&
other.userId == userId &&
other.deviceId == deviceId &&
other.type == type &&
other.createdAt == createdAt &&
other.modifiedAt == modifiedAt &&
other.originalPath == originalPath &&
other.isFavorite == isFavorite &&
other.duration == duration &&
other.exifInfo == exifInfo;
}
@override
int get hashCode {
return id.hashCode ^
deviceAssetId.hashCode ^
userId.hashCode ^
deviceId.hashCode ^
type.hashCode ^
createdAt.hashCode ^
modifiedAt.hashCode ^
originalPath.hashCode ^
isFavorite.hashCode ^
duration.hashCode ^
exifInfo.hashCode;
}
}

View file

@ -1,55 +0,0 @@
import 'dart:convert';
class MapboxInfo {
final bool isEnable;
final String mapboxSecret;
MapboxInfo({
required this.isEnable,
required this.mapboxSecret,
});
MapboxInfo copyWith({
bool? isEnable,
String? mapboxSecret,
}) {
return MapboxInfo(
isEnable: isEnable ?? this.isEnable,
mapboxSecret: mapboxSecret ?? this.mapboxSecret,
);
}
Map<String, dynamic> toMap() {
return {
'isEnable': isEnable,
'mapboxSecret': mapboxSecret,
};
}
factory MapboxInfo.fromMap(Map<String, dynamic> map) {
return MapboxInfo(
isEnable: map['isEnable'] ?? false,
mapboxSecret: map['mapboxSecret'] ?? '',
);
}
String toJson() => json.encode(toMap());
factory MapboxInfo.fromJson(String source) =>
MapboxInfo.fromMap(json.decode(source));
@override
String toString() =>
'MapboxInfo(isEnable: $isEnable, mapboxSecret: $mapboxSecret)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is MapboxInfo &&
other.isEnable == isEnable &&
other.mapboxSecret == mapboxSecret;
}
@override
int get hashCode => isEnable.hashCode ^ mapboxSecret.hashCode;
}

View file

@ -1,99 +0,0 @@
import 'dart:convert';
class ServerInfo {
final String diskSize;
final String diskUse;
final String diskAvailable;
final int diskSizeRaw;
final int diskUseRaw;
final int diskAvailableRaw;
final double diskUsagePercentage;
ServerInfo({
required this.diskSize,
required this.diskUse,
required this.diskAvailable,
required this.diskSizeRaw,
required this.diskUseRaw,
required this.diskAvailableRaw,
required this.diskUsagePercentage,
});
ServerInfo copyWith({
String? diskSize,
String? diskUse,
String? diskAvailable,
int? diskSizeRaw,
int? diskUseRaw,
int? diskAvailableRaw,
double? diskUsagePercentage,
}) {
return ServerInfo(
diskSize: diskSize ?? this.diskSize,
diskUse: diskUse ?? this.diskUse,
diskAvailable: diskAvailable ?? this.diskAvailable,
diskSizeRaw: diskSizeRaw ?? this.diskSizeRaw,
diskUseRaw: diskUseRaw ?? this.diskUseRaw,
diskAvailableRaw: diskAvailableRaw ?? this.diskAvailableRaw,
diskUsagePercentage: diskUsagePercentage ?? this.diskUsagePercentage,
);
}
Map<String, dynamic> toMap() {
return {
'diskSize': diskSize,
'diskUse': diskUse,
'diskAvailable': diskAvailable,
'diskSizeRaw': diskSizeRaw,
'diskUseRaw': diskUseRaw,
'diskAvailableRaw': diskAvailableRaw,
'diskUsagePercentage': diskUsagePercentage,
};
}
factory ServerInfo.fromMap(Map<String, dynamic> map) {
return ServerInfo(
diskSize: map['diskSize'] ?? '',
diskUse: map['diskUse'] ?? '',
diskAvailable: map['diskAvailable'] ?? '',
diskSizeRaw: map['diskSizeRaw']?.toInt() ?? 0,
diskUseRaw: map['diskUseRaw']?.toInt() ?? 0,
diskAvailableRaw: map['diskAvailableRaw']?.toInt() ?? 0,
diskUsagePercentage: map['diskUsagePercentage']?.toDouble() ?? 0.0,
);
}
String toJson() => json.encode(toMap());
factory ServerInfo.fromJson(String source) =>
ServerInfo.fromMap(json.decode(source));
@override
String toString() {
return 'ServerInfo(diskSize: $diskSize, diskUse: $diskUse, diskAvailable: $diskAvailable, diskSizeRaw: $diskSizeRaw, diskUseRaw: $diskUseRaw, diskAvailableRaw: $diskAvailableRaw, diskUsagePercentage: $diskUsagePercentage)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ServerInfo &&
other.diskSize == diskSize &&
other.diskUse == diskUse &&
other.diskAvailable == diskAvailable &&
other.diskSizeRaw == diskSizeRaw &&
other.diskUseRaw == diskUseRaw &&
other.diskAvailableRaw == diskAvailableRaw &&
other.diskUsagePercentage == diskUsagePercentage;
}
@override
int get hashCode {
return diskSize.hashCode ^
diskUse.hashCode ^
diskAvailable.hashCode ^
diskSizeRaw.hashCode ^
diskUseRaw.hashCode ^
diskAvailableRaw.hashCode ^
diskUsagePercentage.hashCode;
}
}

View file

@ -1,29 +1,22 @@
import 'dart:convert';
import 'package:immich_mobile/shared/models/mapbox_info.model.dart';
import 'package:immich_mobile/shared/models/server_version.model.dart';
import 'package:openapi/api.dart';
class ServerInfoState {
final MapboxInfo mapboxInfo;
final ServerVersion serverVersion;
final ServerVersionReponseDto serverVersion;
final bool isVersionMismatch;
final String versionMismatchErrorMessage;
ServerInfoState({
required this.mapboxInfo,
required this.serverVersion,
required this.isVersionMismatch,
required this.versionMismatchErrorMessage,
});
ServerInfoState copyWith({
MapboxInfo? mapboxInfo,
ServerVersion? serverVersion,
ServerVersionReponseDto? serverVersion,
bool? isVersionMismatch,
String? versionMismatchErrorMessage,
}) {
return ServerInfoState(
mapboxInfo: mapboxInfo ?? this.mapboxInfo,
serverVersion: serverVersion ?? this.serverVersion,
isVersionMismatch: isVersionMismatch ?? this.isVersionMismatch,
versionMismatchErrorMessage:
@ -31,32 +24,9 @@ class ServerInfoState {
);
}
Map<String, dynamic> toMap() {
return {
'mapboxInfo': mapboxInfo.toMap(),
'serverVersion': serverVersion.toMap(),
'isVersionMismatch': isVersionMismatch,
'versionMismatchErrorMessage': versionMismatchErrorMessage,
};
}
factory ServerInfoState.fromMap(Map<String, dynamic> map) {
return ServerInfoState(
mapboxInfo: MapboxInfo.fromMap(map['mapboxInfo']),
serverVersion: ServerVersion.fromMap(map['serverVersion']),
isVersionMismatch: map['isVersionMismatch'] ?? false,
versionMismatchErrorMessage: map['versionMismatchErrorMessage'] ?? '',
);
}
String toJson() => json.encode(toMap());
factory ServerInfoState.fromJson(String source) =>
ServerInfoState.fromMap(json.decode(source));
@override
String toString() {
return 'ServerInfoState(mapboxInfo: $mapboxInfo, serverVersion: $serverVersion, isVersionMismatch: $isVersionMismatch, versionMismatchErrorMessage: $versionMismatchErrorMessage)';
return 'ServerInfoState( serverVersion: $serverVersion, isVersionMismatch: $isVersionMismatch, versionMismatchErrorMessage: $versionMismatchErrorMessage)';
}
@override
@ -64,7 +34,6 @@ class ServerInfoState {
if (identical(this, other)) return true;
return other is ServerInfoState &&
other.mapboxInfo == mapboxInfo &&
other.serverVersion == serverVersion &&
other.isVersionMismatch == isVersionMismatch &&
other.versionMismatchErrorMessage == versionMismatchErrorMessage;
@ -72,8 +41,7 @@ class ServerInfoState {
@override
int get hashCode {
return mapboxInfo.hashCode ^
serverVersion.hashCode ^
return serverVersion.hashCode ^
isVersionMismatch.hashCode ^
versionMismatchErrorMessage.hashCode;
}

View file

@ -1,73 +0,0 @@
import 'dart:convert';
class ServerVersion {
final int major;
final int minor;
final int patch;
final int build;
ServerVersion({
required this.major,
required this.minor,
required this.patch,
required this.build,
});
ServerVersion copyWith({
int? major,
int? minor,
int? patch,
int? build,
}) {
return ServerVersion(
major: major ?? this.major,
minor: minor ?? this.minor,
patch: patch ?? this.patch,
build: build ?? this.build,
);
}
Map<String, dynamic> toMap() {
return {
'major': major,
'minor': minor,
'patch': patch,
'build': build,
};
}
factory ServerVersion.fromMap(Map<String, dynamic> map) {
return ServerVersion(
major: map['major']?.toInt() ?? 0,
minor: map['minor']?.toInt() ?? 0,
patch: map['patch']?.toInt() ?? 0,
build: map['build']?.toInt() ?? 0,
);
}
String toJson() => json.encode(toMap());
factory ServerVersion.fromJson(String source) =>
ServerVersion.fromMap(json.decode(source));
@override
String toString() {
return 'ServerVersion(major: $major, minor: $minor, patch: $patch, build: $build)';
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is ServerVersion &&
other.major == major &&
other.minor == minor &&
other.patch == patch &&
other.build == build;
}
@override
int get hashCode {
return major.hashCode ^ minor.hashCode ^ patch.hashCode ^ build.hashCode;
}
}

View file

@ -1,76 +0,0 @@
import 'dart:convert';
class User {
final String id;
final String email;
final String createdAt;
final String firstName;
final String lastName;
User({
required this.id,
required this.email,
required this.createdAt,
required this.firstName,
required this.lastName,
});
User copyWith({
String? id,
String? email,
String? createdAt,
String? firstName,
String? lastName,
}) {
return User(
id: id ?? this.id,
email: email ?? this.email,
createdAt: createdAt ?? this.createdAt,
firstName: firstName ?? this.firstName,
lastName: lastName ?? this.lastName,
);
}
Map<String, dynamic> toMap() {
final result = <String, dynamic>{};
result.addAll({'id': id});
result.addAll({'email': email});
result.addAll({'createdAt': createdAt});
return result;
}
factory User.fromMap(Map<String, dynamic> map) {
return User(
id: map['id'] ?? '',
email: map['email'] ?? '',
createdAt: map['createdAt'] ?? '',
firstName: map['firstName'] ?? '',
lastName: map['lastName'] ?? '',
);
}
String toJson() => json.encode(toMap());
factory User.fromJson(String source) => User.fromMap(json.decode(source));
@override
String toString() =>
'UserInfo(id: $id, email: $email, createdAt: $createdAt)';
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is User &&
other.id == id &&
other.email == email &&
other.createdAt == createdAt &&
other.firstName == firstName &&
other.lastName == lastName;
}
@override
int get hashCode => id.hashCode ^ email.hashCode ^ createdAt.hashCode;
}