From 96a8f415257b6c65483c066036e15f0cb0ffefe2 Mon Sep 17 00:00:00 2001 From: "Florian RICHER (MrDev023)" Date: Tue, 26 Apr 2022 21:41:57 +0200 Subject: [PATCH] Improve scroll end --- lib/widgets/pages/home.dart | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/widgets/pages/home.dart b/lib/widgets/pages/home.dart index 030a84b..202475c 100644 --- a/lib/widgets/pages/home.dart +++ b/lib/widgets/pages/home.dart @@ -82,12 +82,17 @@ class _HomePageState extends State { itemCount: streamElements.length, controller: _scrollController, itemBuilder: (BuildContext context, int index) { - WidgetsBinding.instance!.addPostFrameCallback((timeStamp) { - _scrollController.animateTo( - _scrollController.position.maxScrollExtent, - duration: const Duration(milliseconds: 500), - curve: Curves.easeOut); - }); + if (_scrollController.position.maxScrollExtent - + _scrollController.offset < + 10) { + WidgetsBinding.instance! + .addPostFrameCallback((timeStamp) { + _scrollController.animateTo( + _scrollController.position.maxScrollExtent, + duration: const Duration(milliseconds: 500), + curve: Curves.easeOut); + }); + } return StreamElementCard( streamElement: streamElements[index]); },