Browse Source

made Collection.attributes non-nullable

ashilkn 2 years ago
parent
commit
0327bc26d3
2 changed files with 7 additions and 8 deletions
  1. 5 6
      lib/db/collections_db.dart
  2. 2 2
      lib/models/collection.dart

+ 5 - 6
lib/db/collections_db.dart

@@ -3,7 +3,6 @@ import 'dart:io';
 
 import 'package:path/path.dart';
 import 'package:path_provider/path_provider.dart';
-// ignore: import_of_legacy_library_into_null_safe
 import 'package:photos/models/collection.dart';
 import 'package:sqflite/sqflite.dart';
 import 'package:sqflite_migration/sqflite_migration.dart';
@@ -192,7 +191,7 @@ class CollectionsDB {
   Map<String, dynamic> _getRowForCollection(Collection collection) {
     final row = <String, dynamic>{};
     row[columnID] = collection.id;
-    row[columnOwner] = collection.owner.toJson();
+    row[columnOwner] = collection.owner!.toJson();
     row[columnEncryptedKey] = collection.encryptedKey;
     row[columnKeyDecryptionNonce] = collection.keyDecryptionNonce;
     row[columnName] = collection.name;
@@ -203,16 +202,16 @@ class CollectionsDB {
     row[columnPathDecryptionNonce] = collection.attributes.pathDecryptionNonce;
     row[columnVersion] = collection.attributes.version;
     row[columnSharees] =
-        json.encode(collection.sharees?.map((x) => x?.toMap())?.toList());
+        json.encode(collection.sharees?.map((x) => x?.toMap()).toList());
     row[columnPublicURLs] =
-        json.encode(collection.publicURLs?.map((x) => x?.toMap())?.toList());
+        json.encode(collection.publicURLs?.map((x) => x?.toMap()).toList());
     row[columnUpdationTime] = collection.updationTime;
-    if (collection.isDeleted ?? false) {
+    if (collection.isDeleted) {
       row[columnIsDeleted] = _sqlBoolTrue;
     } else {
       row[columnIsDeleted] = _sqlBoolFalse;
     }
-    row[columnMMdVersion] = collection.mMdVersion ?? 0;
+    row[columnMMdVersion] = collection.mMdVersion;
     row[columnMMdEncodedJson] = collection.mMdEncodedJson ?? '{}';
     return row;
   }

+ 2 - 2
lib/models/collection.dart

@@ -12,7 +12,7 @@ class Collection {
   final String encryptedName;
   final String nameDecryptionNonce;
   final CollectionType type;
-  final CollectionAttributes? attributes;
+  final CollectionAttributes attributes;
   final List<User?>? sharees;
   final List<PublicURL?>? publicURLs;
   final int updationTime;
@@ -114,7 +114,7 @@ class Collection {
       'encryptedName': encryptedName,
       'nameDecryptionNonce': nameDecryptionNonce,
       'type': typeToString(type),
-      'attributes': attributes?.toMap(),
+      'attributes': attributes.toMap(),
       'sharees': sharees?.map((x) => x?.toMap()).toList(),
       'publicURLs': publicURLs?.map((x) => x?.toMap()).toList(),
       'updationTime': updationTime,