From 16d089a62cf701baff6a89ff67d04a705329f164 Mon Sep 17 00:00:00 2001 From: Krushna Kanta Rout <129386740+krushnarout@users.noreply.github.com> Date: Sat, 3 Jan 2026 23:15:15 +0530 Subject: [PATCH] fix guard ScrollController with positions check --- app/lib/pages/speech_profile/page.dart | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/app/lib/pages/speech_profile/page.dart b/app/lib/pages/speech_profile/page.dart index 1fb7fe5f6a..82a90a53dd 100644 --- a/app/lib/pages/speech_profile/page.dart +++ b/app/lib/pages/speech_profile/page.dart @@ -72,6 +72,7 @@ class _SpeechProfilePageState extends State with TickerProvid @override void dispose() { + _scrollController.dispose(); _questionAnimationController.dispose(); super.dispose(); } @@ -79,14 +80,16 @@ class _SpeechProfilePageState extends State with TickerProvid final ScrollController _scrollController = ScrollController(); void scrollDown() async { - if (_scrollController.hasClients) { - await Future.delayed(const Duration(milliseconds: 250)); - _scrollController.animateTo( - _scrollController.position.maxScrollExtent, - duration: const Duration(milliseconds: 200), - curve: Curves.easeOut, - ); - } + await Future.delayed(const Duration(milliseconds: 250)); + + if (!mounted) return; + if (_scrollController.positions.isEmpty) return; + + _scrollController.animateTo( + _scrollController.position.maxScrollExtent, + duration: const Duration(milliseconds: 200), + curve: Curves.easeOut, + ); } @override