From 24e9328a77ade52e0e43fda05df3a453d8a75486 Mon Sep 17 00:00:00 2001 From: Sahil-Simform Date: Thu, 12 Dec 2024 14:32:30 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Fixed=20mounter=20issue?= =?UTF-8?q?=20inside=20the=20`=5FscrollIntoView`=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 2 ++ lib/src/showcase.dart | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8414db35..c67c9d86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ - Feature [#478](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/478) - Added feasibility to change auto scroll widget alignment `scrollAlignment`. - Feature ✨: Added `enableAutoScroll` to `showcase`. +- Fix [#489](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/pull/489) - Fixed + mounter issue inside the `_scrollIntoView` function ## [3.0.0] - [BREAKING] Fixed [#434](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/434) removed deprecated text style after Flutter 3.22 follow [migration guide](https://docs.flutter.dev/release/breaking-changes/3-19-deprecations#texttheme) diff --git a/lib/src/showcase.dart b/lib/src/showcase.dart index ae9fad84..27a3eb09 100644 --- a/lib/src/showcase.dart +++ b/lib/src/showcase.dart @@ -603,12 +603,15 @@ class _ShowcaseState extends State { void _scrollIntoView() { WidgetsBinding.instance.addPostFrameCallback((timeStamp) async { + final keyContext = widget.key.currentContext; + if (!mounted || (keyContext?.mounted ?? true)) return; setState(() => _isScrollRunning = true); await Scrollable.ensureVisible( - widget.key.currentContext!, + keyContext!, duration: showCaseWidgetState.widget.scrollDuration, alignment: widget.scrollAlignment, ); + if (!mounted) return; setState(() => _isScrollRunning = false); }); }