migrated collection.dart to null safety
This commit is contained in:
parent
6201b77809
commit
ee3ca77f72
|
@ -1,5 +1,3 @@
|
||||||
// @dart=2.9
|
|
||||||
|
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:core';
|
import 'dart:core';
|
||||||
|
|
||||||
|
@ -7,21 +5,21 @@ import 'package:photos/models/magic_metadata.dart';
|
||||||
|
|
||||||
class Collection {
|
class Collection {
|
||||||
final int id;
|
final int id;
|
||||||
final User owner;
|
final User? owner;
|
||||||
final String encryptedKey;
|
final String encryptedKey;
|
||||||
final String keyDecryptionNonce;
|
final String? keyDecryptionNonce;
|
||||||
final String name;
|
final String name;
|
||||||
final String encryptedName;
|
final String encryptedName;
|
||||||
final String nameDecryptionNonce;
|
final String nameDecryptionNonce;
|
||||||
final CollectionType type;
|
final CollectionType type;
|
||||||
final CollectionAttributes attributes;
|
final CollectionAttributes? attributes;
|
||||||
final List<User> sharees;
|
final List<User?>? sharees;
|
||||||
final List<PublicURL> publicURLs;
|
final List<PublicURL?>? publicURLs;
|
||||||
final int updationTime;
|
final int updationTime;
|
||||||
final bool isDeleted;
|
final bool isDeleted;
|
||||||
String mMdEncodedJson;
|
String? mMdEncodedJson;
|
||||||
int mMdVersion = 0;
|
int mMdVersion = 0;
|
||||||
CollectionMagicMetadata _mmd;
|
CollectionMagicMetadata? _mmd;
|
||||||
|
|
||||||
CollectionMagicMetadata get magicMetadata =>
|
CollectionMagicMetadata get magicMetadata =>
|
||||||
_mmd ?? CollectionMagicMetadata.fromEncodedJson(mMdEncodedJson ?? '{}');
|
_mmd ?? CollectionMagicMetadata.fromEncodedJson(mMdEncodedJson ?? '{}');
|
||||||
|
@ -70,21 +68,21 @@ class Collection {
|
||||||
}
|
}
|
||||||
|
|
||||||
Collection copyWith({
|
Collection copyWith({
|
||||||
int id,
|
int? id,
|
||||||
User owner,
|
User? owner,
|
||||||
String encryptedKey,
|
String? encryptedKey,
|
||||||
String keyDecryptionNonce,
|
String? keyDecryptionNonce,
|
||||||
String name,
|
String? name,
|
||||||
String encryptedName,
|
String? encryptedName,
|
||||||
String nameDecryptionNonce,
|
String? nameDecryptionNonce,
|
||||||
CollectionType type,
|
CollectionType? type,
|
||||||
CollectionAttributes attributes,
|
CollectionAttributes? attributes,
|
||||||
List<User> sharees,
|
List<User>? sharees,
|
||||||
List<PublicURL> publicURLs,
|
List<PublicURL>? publicURLs,
|
||||||
int updationTime,
|
int? updationTime,
|
||||||
bool isDeleted,
|
bool? isDeleted,
|
||||||
String mMdEncodedJson,
|
String? mMdEncodedJson,
|
||||||
int mMdVersion,
|
int? mMdVersion,
|
||||||
}) {
|
}) {
|
||||||
final Collection result = Collection(
|
final Collection result = Collection(
|
||||||
id ?? this.id,
|
id ?? this.id,
|
||||||
|
@ -117,14 +115,14 @@ class Collection {
|
||||||
'nameDecryptionNonce': nameDecryptionNonce,
|
'nameDecryptionNonce': nameDecryptionNonce,
|
||||||
'type': typeToString(type),
|
'type': typeToString(type),
|
||||||
'attributes': attributes?.toMap(),
|
'attributes': attributes?.toMap(),
|
||||||
'sharees': sharees?.map((x) => x?.toMap())?.toList(),
|
'sharees': sharees?.map((x) => x?.toMap()).toList(),
|
||||||
'publicURLs': publicURLs?.map((x) => x?.toMap())?.toList(),
|
'publicURLs': publicURLs?.map((x) => x?.toMap()).toList(),
|
||||||
'updationTime': updationTime,
|
'updationTime': updationTime,
|
||||||
'isDeleted': isDeleted,
|
'isDeleted': isDeleted,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
factory Collection.fromMap(Map<String, dynamic> map) {
|
factory Collection.fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
throw Exception('Argument is null');
|
throw Exception('Argument is null');
|
||||||
}
|
}
|
||||||
|
@ -162,9 +160,9 @@ enum CollectionType {
|
||||||
}
|
}
|
||||||
|
|
||||||
class CollectionAttributes {
|
class CollectionAttributes {
|
||||||
final String encryptedPath;
|
final String? encryptedPath;
|
||||||
final String pathDecryptionNonce;
|
final String? pathDecryptionNonce;
|
||||||
final int version;
|
final int? version;
|
||||||
|
|
||||||
CollectionAttributes({
|
CollectionAttributes({
|
||||||
this.encryptedPath,
|
this.encryptedPath,
|
||||||
|
@ -184,7 +182,7 @@ class CollectionAttributes {
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
factory CollectionAttributes.fromMap(Map<String, dynamic> map) {
|
factory CollectionAttributes.fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
throw Exception('Argument is null');
|
throw Exception('Argument is null');
|
||||||
}
|
}
|
||||||
|
@ -198,13 +196,13 @@ class CollectionAttributes {
|
||||||
}
|
}
|
||||||
|
|
||||||
class User {
|
class User {
|
||||||
int id;
|
int? id;
|
||||||
String email;
|
String email;
|
||||||
String name;
|
String? name;
|
||||||
|
|
||||||
User({
|
User({
|
||||||
this.id,
|
this.id,
|
||||||
this.email,
|
required this.email,
|
||||||
this.name,
|
this.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -216,7 +214,7 @@ class User {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
factory User.fromMap(Map<String, dynamic> map) {
|
factory User.fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
throw Exception('Argument is null');
|
throw Exception('Argument is null');
|
||||||
}
|
}
|
||||||
|
@ -237,15 +235,15 @@ class PublicURL {
|
||||||
String url;
|
String url;
|
||||||
int deviceLimit;
|
int deviceLimit;
|
||||||
int validTill;
|
int validTill;
|
||||||
bool enableDownload = true;
|
bool enableDownload;
|
||||||
bool passwordEnabled = false;
|
bool passwordEnabled;
|
||||||
|
|
||||||
PublicURL({
|
PublicURL({
|
||||||
this.url,
|
required this.url,
|
||||||
this.deviceLimit,
|
required this.deviceLimit,
|
||||||
this.validTill,
|
required this.validTill,
|
||||||
this.enableDownload,
|
this.enableDownload = true,
|
||||||
this.passwordEnabled,
|
this.passwordEnabled = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toMap() {
|
||||||
|
@ -258,7 +256,7 @@ class PublicURL {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
factory PublicURL.fromMap(Map<String, dynamic> map) {
|
factory PublicURL.fromMap(Map<String, dynamic>? map) {
|
||||||
if (map == null) {
|
if (map == null) {
|
||||||
throw Exception('Argument is null');
|
throw Exception('Argument is null');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue