aboutsummaryrefslogtreecommitdiff
path: root/lib/main.dart
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2020-06-04 00:14:06 +0530
committerAkshay Nair <phenax5@gmail.com>2020-06-04 00:14:06 +0530
commit497646527fd598c9d37b27220ad148c91a1f9225 (patch)
tree0369f9995957857afcfd3e52dba523cdc65998ef /lib/main.dart
parente8c7759250cf7a7eb1fc0047a4cef27cd75ab15b (diff)
downloaddaft-launcher-497646527fd598c9d37b27220ad148c91a1f9225.tar.gz
daft-launcher-497646527fd598c9d37b27220ad148c91a1f9225.zip
Refactors datetime to the top
Diffstat (limited to 'lib/main.dart')
-rw-r--r--lib/main.dart17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/main.dart b/lib/main.dart
index a223fb7..c41c1ad 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -15,10 +15,6 @@ void main() {
}
class MyAppState extends StreamState<MyApp> {
- // Streams
- final Stream<DateTime> time$ =
- Stream.periodic(Duration(seconds: 1), (_x) => DateTime.now()).asBroadcastStream();
-
// State
final config = StreamStateValue<Config>(
stream$: getConfig$(),
@@ -28,6 +24,10 @@ class MyAppState extends StreamState<MyApp> {
stream$: getFavorites$(),
value: [],
);
+ final dateTime = StreamStateValue<DateTime>(
+ stream$: Stream.periodic(Duration(seconds: 1), (_x) => DateTime.now()).asBroadcastStream(),
+ value: DateTime.now(),
+ );
void initState() {
super.initState();
initStateValue(config);
@@ -36,12 +36,6 @@ class MyAppState extends StreamState<MyApp> {
initFavorites();
}
- @override
- void dispose() {
- super.dispose();
- time$.drain();
- }
-
ThemeData getLightTheme() {
return ThemeData(brightness: Brightness.light);
}
@@ -84,8 +78,7 @@ class MyAppState extends StreamState<MyApp> {
controller: PageController(keepPage: true),
children: [
HomeView(
- time$: time$,
- defaultTime: DateTime.now(),
+ dateTime: dateTime.value,
favoriteApps: favoriteApps.value,
),
AppsView(),