Skip to content

Commit be4b8a2

Browse files
committed
fix(forum): only provide scrolling functions when available
Do not do it when have no positions.
1 parent d96cfa9 commit be4b8a2

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

lib/features/forum/view/forum_page.dart

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,17 @@ class _ForumPageState extends State<ForumPage> with SingleTickerProviderStateMix
111111
const curve = Curves.ease;
112112
switch (tabController.index) {
113113
case _pinnedTabIndex:
114-
_pinnedScrollController.animateTo(0, duration: duration, curve: curve);
114+
if (_pinnedScrollController.hasClients) {
115+
_pinnedScrollController.animateTo(0, duration: duration, curve: curve);
116+
}
115117
case _threadTabIndex:
116-
_threadScrollController.animateTo(0, duration: duration, curve: curve);
118+
if (_threadScrollController.hasClients) {
119+
_threadScrollController.animateTo(0, duration: duration, curve: curve);
120+
}
117121
case _subredditTabIndex:
118-
_subredditScrollController.animateTo(0, duration: duration, curve: curve);
122+
if (_subredditScrollController.hasClients) {
123+
_subredditScrollController.animateTo(0, duration: duration, curve: curve);
124+
}
119125
}
120126
},
121127
)
@@ -151,7 +157,13 @@ class _ForumPageState extends State<ForumPage> with SingleTickerProviderStateMix
151157
case MenuActions.openInBrowser:
152158
await context.dispatchAsUrl(widget.forumUrl, external: true);
153159
case MenuActions.backToTop:
154-
await _threadScrollController.animateTo(0, curve: Curves.ease, duration: const Duration(milliseconds: 500));
160+
if (_threadScrollController.hasClients) {
161+
await _threadScrollController.animateTo(
162+
0,
163+
curve: Curves.ease,
164+
duration: const Duration(milliseconds: 500),
165+
);
166+
}
155167
case MenuActions.reverseOrder:
156168
;
157169
case MenuActions.debugViewLog:

0 commit comments

Comments
 (0)