Browse Source

added device null check to select db query

Abhinav-grd 4 years ago
parent
commit
c9a41bc71f
1 changed files with 19 additions and 9 deletions
  1. 19 9
      lib/db/files_db.dart

+ 19 - 9
lib/db/files_db.dart

@@ -452,16 +452,26 @@ class FilesDB {
     int creationTime,
     int creationTime,
   ) async {
   ) async {
     final db = await instance.database;
     final db = await instance.database;
-    final rows = await db.query(
-      table,
-      where: '''$columnTitle=? AND $columnDeviceFolder=? AND 
+    final rows = await (deviceFolder != null
+        ? db.query(
+            table,
+            where: '''$columnTitle=? AND $columnDeviceFolder=? AND 
           $columnCreationTime=?''',
           $columnCreationTime=?''',
-      whereArgs: [
-        title,
-        deviceFolder ?? "",
-        creationTime,
-      ],
-    );
+            whereArgs: [
+              title,
+              deviceFolder,
+              creationTime,
+            ],
+          )
+        : db.query(
+            table,
+            where: '''$columnTitle=? AND 
+          $columnCreationTime=?''',
+            whereArgs: [
+              title,
+              creationTime,
+            ],
+          ));
     if (rows.isNotEmpty) {
     if (rows.isNotEmpty) {
       return _convertToFiles(rows);
       return _convertToFiles(rows);
     } else {
     } else {