Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use PinnedHeaderSliver instead of SliverPersistentHeader #1757

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 8 additions & 36 deletions lib/app/views/app_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -463,20 +463,15 @@ class _AppPageState extends ConsumerState<AppPage> {
slivers: [
SliverMainAxisGroup(
slivers: [
SliverPersistentHeader(
pinned: true,
delegate: _SliverTitleDelegate(
child: ColoredBox(
color: Theme.of(context).colorScheme.surface,
child: Padding(
key: _sliverTitleWrapperGlobalKey,
padding: const EdgeInsets.only(
left: 18.0, right: 18.0, bottom: 12.0, top: 4.0),
child: _buildTitle(context),
),
PinnedHeaderSliver(
child: ColoredBox(
color: Theme.of(context).colorScheme.surface,
child: Padding(
key: _sliverTitleWrapperGlobalKey,
padding: const EdgeInsets.only(
left: 18.0, right: 18.0, bottom: 12.0, top: 4.0),
child: _buildTitle(context),
),
// Header height = title height + vertical padding
height: _getTitleHeight(context) + 16,
),
),
if (widget.headerSliver != null)
Expand Down Expand Up @@ -1021,29 +1016,6 @@ class _VisibilityListenerState extends State<_VisibilityListener> {
}
}

class _SliverTitleDelegate extends SliverPersistentHeaderDelegate {
_SliverTitleDelegate({
required this.height,
required this.child,
});
final double height;
final Widget child;

@override
double get minExtent => height;
@override
double get maxExtent => height;

@override
Widget build(
BuildContext context, double shrinkOffset, bool overlapsContent) {
return child;
}

@override
bool shouldRebuild(_SliverTitleDelegate oldDelegate) => true;
}

class _NoImplicitScrollPhysics extends ScrollPhysics {
const _NoImplicitScrollPhysics({super.parent});

Expand Down
Loading