From e8c7759250cf7a7eb1fc0047a4cef27cd75ab15b Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 4 Jun 2020 00:05:13 +0530 Subject: fixes empty list issues --- .flutter-plugins-dependencies | 2 +- TODO.md | 2 ++ lib/data/favorites.dart | 4 ++-- lib/main.dart | 5 ----- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index ff3074a..71490bc 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+3/","dependencies":[]}],"android":[{"name":"android_intent","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.7+2/","dependencies":[]},{"name":"device_apps","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/device_apps-1.0.9/","dependencies":[]},{"name":"shared_preferences","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+3/","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]}]},"dependencyGraph":[{"name":"android_intent","dependencies":[]},{"name":"device_apps","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]}],"date_created":"2020-06-03 23:34:53.607416","version":"1.19.0-2.0.pre.214"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"shared_preferences","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+3/","dependencies":[]}],"android":[{"name":"android_intent","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/android_intent-0.3.7+2/","dependencies":[]},{"name":"device_apps","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/device_apps-1.0.9/","dependencies":[]},{"name":"shared_preferences","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+3/","dependencies":[]}],"macos":[{"name":"shared_preferences_macos","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+10/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/home/akshayn/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+7/","dependencies":[]}]},"dependencyGraph":[{"name":"android_intent","dependencies":[]},{"name":"device_apps","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]}],"date_created":"2020-06-03 23:39:26.967680","version":"1.19.0-2.0.pre.214"} \ No newline at end of file diff --git a/TODO.md b/TODO.md index 12482a1..d7209dd 100644 --- a/TODO.md +++ b/TODO.md @@ -16,6 +16,8 @@ - [X] Get rid of defaultTime and loading - [X] Create favorites list - [X] Get favorites list from a persistent store + - [ ] Remove from favorites + - [ ] Change the order of favorites? ## Applications list - [X] Create app list diff --git a/lib/data/favorites.dart b/lib/data/favorites.dart index 2e389b8..45f1e00 100644 --- a/lib/data/favorites.dart +++ b/lib/data/favorites.dart @@ -8,7 +8,7 @@ const String SEPERATOR = ','; StreamController> favorites_$ = StreamController>.broadcast(); Future getApplication(String pkg) async { - if (pkg.length == 0) return null; + if (pkg == null || pkg.length == 0) return null; try { return DeviceApps.getApp(pkg); } catch(e) { @@ -49,7 +49,7 @@ void setFavorites(List favs) async { } void addToFavorites(Application app) async { - List fs = await getFavorites(); + List fs = await getFavorites() as List; var matching = fs.where((a) => a.packageName == app.packageName); if(matching.length == 0) { diff --git a/lib/main.dart b/lib/main.dart index b11886a..a223fb7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -34,11 +34,6 @@ class MyAppState extends StreamState { initConfig(); initStateValue(favoriteApps); initFavorites(); - - SharedPreferences.getInstance().then((instance) { - var val = instance.getString('favorites'); - debugPrint('Hello |${val}| ${val.length}'); - }); } @override -- cgit v1.3.1