From 96dbddb10ce1e83a3cef7ceb2b6f8d276a5e4518 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 15 Jan 2020 23:29:31 +0100 Subject: [PATCH] Fix scrolling to last element --- lib/pages/list/list.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/pages/list/list.dart b/lib/pages/list/list.dart index 5602739..a683890 100644 --- a/lib/pages/list/list.dart +++ b/lib/pages/list/list.dart @@ -61,8 +61,16 @@ class _ListPageState extends State { if (i.isOdd) return Divider(); final index = i ~/ 2; + + // This handles the case if there are no more elements in the list left which can be provided by the api + if(VikunjaGlobal.of(context).taskService.maxPages == _currentPage && index == _tasks.length - 1) return null; + if (index >= _tasks.length && VikunjaGlobal.of(context).taskService.maxPages < _currentPage) { _currentPage++; + // FIXME: This does not get loaded until some time after the next (_tasks.length + 1) entry should have been rendered + // This leads to errors because the render method tries to access an entry of _tasks with an index which does not exist + // The load function gets actually called after the return below. I assume this is because of the setState() invocation + // in _loadTasksForPage()? _loadTasksForPage(_currentPage); } return TaskTile(