From 497646527fd598c9d37b27220ad148c91a1f9225 Mon Sep 17 00:00:00 2001 From: Akshay Nair Date: Thu, 4 Jun 2020 00:14:06 +0530 Subject: Refactors datetime to the top --- lib/main.dart | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'lib/main.dart') 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 { - // Streams - final Stream time$ = - Stream.periodic(Duration(seconds: 1), (_x) => DateTime.now()).asBroadcastStream(); - // State final config = StreamStateValue( stream$: getConfig$(), @@ -28,6 +24,10 @@ class MyAppState extends StreamState { stream$: getFavorites$(), value: [], ); + final dateTime = StreamStateValue( + 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 { initFavorites(); } - @override - void dispose() { - super.dispose(); - time$.drain(); - } - ThemeData getLightTheme() { return ThemeData(brightness: Brightness.light); } @@ -84,8 +78,7 @@ class MyAppState extends StreamState { controller: PageController(keepPage: true), children: [ HomeView( - time$: time$, - defaultTime: DateTime.now(), + dateTime: dateTime.value, favoriteApps: favoriteApps.value, ), AppsView(), -- cgit v1.3.1