패키지, 저장소 및 앱 카테고리 검색

flutter_sticky_header 표지
패키지 상세v0.8.0

flutter_sticky_header

슬리버로 스티키 헤더를 구현한 플러터. CustomScrollView에서 사용합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
30.6만
좋아요
943
Pub 점수
150

패키지 설치

flutter pub add flutter_sticky_header

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

슬라이버를 사용하여 CustomScrollView 내에서 스틱 헤더를 구현하는 플러터 패키지입니다. 사용자가 목록이나 그리드를 스크롤할 때 헤더가 스크롤 가능한 콘텐츠의 상단에 계속 표시되도록 하여 탐색과 시각적 구성에 도움을 줍니다. 연락처, 메시지 또는 분류된 데이터와 같은 그룹화된 항목이 포함된 긴 목록에 이상적입니다. 이 패키지는 가볍고 잘 문서화되어 있으며 모든 주요 플랫폼과 호환됩니다.

사용 사례

  • 그룹화된 목록 보기
  • 알파벳 헤더가 있는 연락처 목록
  • 날짜 헤더가 있는 메시지 스레드
  • 분류된 제품 목록
  • 섹션 헤더가 있는 스크롤 가능한 대시보드

주요 기능

  • Sliver 기반 구현
  • 자동 헤더 고정
  • 사용자 지정 가능한 헤더 스타일
  • 부드러운 스크롤 동작
  • 크로스 플랫폼 지원
  • CustomScrollView와의 간편한 통합

적합한 대상

  • 섹션을 포함한 스크롤 가능한 목록을 구축하는 개발자
  • 시각적으로 정리된 콘텐츠가 필요한 앱
  • 성능 최적화 헤더가 필요한 프로젝트
  • 플랫폼 일관성을 우선시하는 팀

고려 사항

  • CustomScrollView 내에서 사용해야 합니다
  • 복잡한 헤더의 경우 추가적인 레이아웃 조정이 필요할 수 있습니다
  • 슬리버 스크롤 컨텍스트가 아닌 경우 적합하지 않습니다
  • 기본 스타일링을 넘어서는 사용자 정의가 제한적
  • 매우 큰 데이터 세트와의 성능 영향

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flutter_sticky_header

A Flutter implementation of sticky headers with a sliver as a child.

Pub Donate

Screenshot

Features

  • Accepts one sliver as content.
  • Header can overlap its sliver (useful for sticky side header for example).
  • Notifies when the header scrolls outside the viewport.
  • Can scroll in any direction.
  • Supports overlapping (AppBars for example).
  • Supports not sticky headers (with sticky: false parameter).
  • Supports a controller which notifies the scroll offset of the current sticky header.

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  flutter_sticky_header:

In your library add the following import:

import 'package:flutter_sticky_header/flutter_sticky_header.dart';

For help getting started with Flutter, view the online documentation.

SliverStickyHeader

You can place one or multiple SliverStickyHeaders inside a CustomScrollView.

SliverStickyHeader(
  header: Container(
    height: 60.0,
    color: Colors.lightBlue,
    padding: EdgeInsets.symmetric(horizontal: 16.0),
    alignment: Alignment.centerLeft,
    child: Text(
      'Header #0',
      style: const TextStyle(color: Colors.white),
    ),
  ),
  sliver: SliverList(
    delegate: SliverChildBuilderDelegate(
      (context, i) => ListTile(
            leading: CircleAvatar(
              child: Text('0'),
            ),
            title: Text('List tile #$i'),
          ),
      childCount: 4,
    ),
  ),
);

SliverStickyHeader.builder

If you want to change the header layout during its scroll, you can use the SliverStickyHeader.builder constructor.

The example belows changes the opacity of the header as it scrolls off the viewport.

SliverStickyHeader.builder(
  builder: (context, state) => Container(
        height: 60.0,
        color: (state.isPinned ? Colors.pink : Colors.lightBlue)
            .withOpacity(1.0 - state.scrollPercentage),
        padding: EdgeInsets.symmetric(horizontal: 16.0),
        alignment: Alignment.centerLeft,
        child: Text(
          'Header #1',
          style: const TextStyle(color: Colors.white),
        ),
      ),
  sliver: SliverList(
    delegate: SliverChildBuilderDelegate(
      (context, i) => ListTile(
            leading: CircleAvatar(
              child: Text('0'),
            ),
            title: Text('List tile #$i'),
          ),
      childCount: 4,
    ),
  ),
);

You can find more examples in the Example project.

Sponsoring

I'm working on my packages on my free-time, but I don't have as much time as I would. If this package or any other package I created is helping you, please consider to sponsor me. By doing so, I will prioritize your issues or your pull-requests before the others.

Changelog

Please see the Changelog page to know what's recently changed.

Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a new feature, please send a pull request.

Thanks

:clap: Thanks to slightfoot with it's RenderBox version (https://github.com/slightfoot/flutter_sticky_headers) which unintentionally challenged me to work in this RenderSliver version.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트