From 2a0cb669c5d4c67deb4f1dce6806855bf9d56e19 Mon Sep 17 00:00:00 2001 From: Jon Zuka Date: Wed, 6 Nov 2024 00:19:12 +0100 Subject: [PATCH 1/2] fix(flutter_todos): use ListView.builder for scrollable view --- .../view/todos_overview_page.dart | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/examples/flutter_todos/lib/todos_overview/view/todos_overview_page.dart b/examples/flutter_todos/lib/todos_overview/view/todos_overview_page.dart index 3d63eea3129..24fcd4965a0 100644 --- a/examples/flutter_todos/lib/todos_overview/view/todos_overview_page.dart +++ b/examples/flutter_todos/lib/todos_overview/view/todos_overview_page.dart @@ -98,34 +98,36 @@ class TodosOverviewView extends StatelessWidget { ); } } - - return CupertinoScrollbar( - child: ListView( - children: [ - for (final todo in state.filteredTodos) - TodoListTile( - todo: todo, - onToggleCompleted: (isCompleted) { - context.read().add( - TodosOverviewTodoCompletionToggled( - todo: todo, - isCompleted: isCompleted, - ), - ); - }, - onDismissed: (_) { - context - .read() - .add(TodosOverviewTodoDeleted(todo)); - }, - onTap: () { - Navigator.of(context).push( - EditTodoPage.route(initialTodo: todo), + return ListView.builder( + itemCount: state.filteredTodos.length, + itemBuilder: (_, idx) { + final todo = state.filteredTodos.elementAt(idx); + return TodoListTile( + todo: todo, + onToggleCompleted: (isCompleted) { + context.read().add( + TodosOverviewTodoCompletionToggled( + todo: todo, + isCompleted: isCompleted, + ), ); - }, - ), - ], - ), + }, + onDismissed: (_) { + context.read().add( + TodosOverviewTodoDeleted( + todo, + ), + ); + }, + onTap: () { + Navigator.of(context).push( + EditTodoPage.route( + initialTodo: todo, + ), + ); + }, + ); + }, ); }, ), From a6898ea48da552b54003a72514cf1317655f8601 Mon Sep 17 00:00:00 2001 From: Felix Angelov Date: Sat, 16 Nov 2024 16:27:09 -0600 Subject: [PATCH 2/2] chore: minor adjustments --- .../view/todos_overview_page.dart | 59 +++++++++---------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/examples/flutter_todos/lib/todos_overview/view/todos_overview_page.dart b/examples/flutter_todos/lib/todos_overview/view/todos_overview_page.dart index 24fcd4965a0..97880af4302 100644 --- a/examples/flutter_todos/lib/todos_overview/view/todos_overview_page.dart +++ b/examples/flutter_todos/lib/todos_overview/view/todos_overview_page.dart @@ -98,36 +98,35 @@ class TodosOverviewView extends StatelessWidget { ); } } - return ListView.builder( - itemCount: state.filteredTodos.length, - itemBuilder: (_, idx) { - final todo = state.filteredTodos.elementAt(idx); - return TodoListTile( - todo: todo, - onToggleCompleted: (isCompleted) { - context.read().add( - TodosOverviewTodoCompletionToggled( - todo: todo, - isCompleted: isCompleted, - ), - ); - }, - onDismissed: (_) { - context.read().add( - TodosOverviewTodoDeleted( - todo, - ), - ); - }, - onTap: () { - Navigator.of(context).push( - EditTodoPage.route( - initialTodo: todo, - ), - ); - }, - ); - }, + + return CupertinoScrollbar( + child: ListView.builder( + itemCount: state.filteredTodos.length, + itemBuilder: (_, index) { + final todo = state.filteredTodos.elementAt(index); + return TodoListTile( + todo: todo, + onToggleCompleted: (isCompleted) { + context.read().add( + TodosOverviewTodoCompletionToggled( + todo: todo, + isCompleted: isCompleted, + ), + ); + }, + onDismissed: (_) { + context + .read() + .add(TodosOverviewTodoDeleted(todo)); + }, + onTap: () { + Navigator.of(context).push( + EditTodoPage.route(initialTodo: todo), + ); + }, + ); + }, + ), ); }, ),