From 504cace66dbc66d414f6b3d07db4420357f59811 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Fri, 20 Oct 2023 09:41:44 +0200 Subject: [PATCH 1/2] fix(neon_dashboard): Fix widgets reloading scrolling back up Signed-off-by: jld3103 --- packages/neon/neon_dashboard/lib/src/pages/main.dart | 1 + packages/neon/neon_dashboard/lib/src/widgets/widget.dart | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/neon/neon_dashboard/lib/src/pages/main.dart b/packages/neon/neon_dashboard/lib/src/pages/main.dart index 2a19b6ad..1cc456c1 100644 --- a/packages/neon/neon_dashboard/lib/src/pages/main.dart +++ b/packages/neon/neon_dashboard/lib/src/pages/main.dart @@ -38,6 +38,7 @@ class DashboardMainPage extends StatelessWidget { return Center( child: NeonListView.custom( + scrollKey: 'dashboard', isLoading: snapshot.isLoading, error: snapshot.error, onRefresh: bloc.refresh, diff --git a/packages/neon/neon_dashboard/lib/src/widgets/widget.dart b/packages/neon/neon_dashboard/lib/src/widgets/widget.dart index 7e09e20b..4c3844bc 100644 --- a/packages/neon/neon_dashboard/lib/src/widgets/widget.dart +++ b/packages/neon/neon_dashboard/lib/src/widgets/widget.dart @@ -36,6 +36,7 @@ class DashboardWidget extends StatelessWidget { borderRadius: const BorderRadius.all(Radius.circular(12)), child: ListView( padding: const EdgeInsets.all(8), + key: PageStorageKey('dashboard-${widget.id}'), children: [ ListTile( title: Text( From 362edce158ecf60eb482b071b2cf2da8d19a441f Mon Sep 17 00:00:00 2001 From: jld3103 Date: Fri, 20 Oct 2023 16:05:41 +0200 Subject: [PATCH 2/2] fix(neon): Require a scrollKey for NeonListView Signed-off-by: jld3103 --- packages/neon/neon/lib/src/widgets/list_view.dart | 8 ++++---- .../neon/neon/lib/src/widgets/unified_search_results.dart | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/neon/neon/lib/src/widgets/list_view.dart b/packages/neon/neon/lib/src/widgets/list_view.dart index 142e93a0..9e16aa49 100644 --- a/packages/neon/neon/lib/src/widgets/list_view.dart +++ b/packages/neon/neon/lib/src/widgets/list_view.dart @@ -8,8 +8,8 @@ class NeonListView extends StatelessWidget { required this.error, required this.onRefresh, required final NullableIndexedWidgetBuilder itemBuilder, + required this.scrollKey, final int? itemCount, - this.scrollKey, this.topFixedChildren, this.topScrollingChildren, super.key, @@ -23,7 +23,7 @@ class NeonListView extends StatelessWidget { required this.error, required this.onRefresh, required this.sliver, - this.scrollKey, + required this.scrollKey, this.topFixedChildren, this.topScrollingChildren, super.key, @@ -32,7 +32,7 @@ class NeonListView extends StatelessWidget { final bool isLoading; final Object? error; final RefreshCallback onRefresh; - final String? scrollKey; + final String scrollKey; final List? topFixedChildren; final List? topScrollingChildren; final Widget sliver; @@ -46,7 +46,7 @@ class NeonListView extends StatelessWidget { key: refreshIndicatorKey, onRefresh: onRefresh, child: CustomScrollView( - key: scrollKey != null ? PageStorageKey(scrollKey!) : null, + key: PageStorageKey(scrollKey), primary: true, slivers: [ if (topFixedChildren != null) diff --git a/packages/neon/neon/lib/src/widgets/unified_search_results.dart b/packages/neon/neon/lib/src/widgets/unified_search_results.dart index 166f3c2e..1f7d1cef 100644 --- a/packages/neon/neon/lib/src/widgets/unified_search_results.dart +++ b/packages/neon/neon/lib/src/widgets/unified_search_results.dart @@ -32,6 +32,7 @@ class NeonUnifiedSearchResults extends StatelessWidget { final values = results.data?.entries.toList(); return NeonListView( + scrollKey: 'unified-search', isLoading: results.isLoading, error: results.error, onRefresh: bloc.refresh,