From: Scott Murray Date: Thu, 21 Dec 2023 22:37:57 +0000 (-0500) Subject: Fix late initialization warning X-Git-Tag: 17.90.0~9 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=fcd868bd73d35bd79074f3425317152565aeb275;p=apps%2Fflutter-ics-homescreen.git Fix late initialization warning A late initialization warning was being triggered when leaving the home/dashboard page when the random hybrid animation is disabled. Initialize the associated timer member as null and add logic to avoid referencing it in the non-random case where the timer does not get created. Bug-AGL: SPEC-5027 Change-Id: I63bd21db3005f70f2fe0d2d34181d0079cd25b00 Signed-off-by: Scott Murray --- diff --git a/lib/presentation/screens/dashboard/widgets/dashboard_content.dart b/lib/presentation/screens/dashboard/widgets/dashboard_content.dart index 7e4c469..1d25fdf 100644 --- a/lib/presentation/screens/dashboard/widgets/dashboard_content.dart +++ b/lib/presentation/screens/dashboard/widgets/dashboard_content.dart @@ -15,7 +15,7 @@ class DashBoardState extends ConsumerState late AnimationController _animationController; late Animation _animation; static bool _isAnimationPlayed = false; - late Timer timer; + Timer? timer = null; @override void initState() { @@ -53,7 +53,8 @@ class DashBoardState extends ConsumerState @override void dispose() { _animationController.dispose(); - timer.cancel(); + if (timer != null) + timer?.cancel(); super.dispose(); }