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

sliver_snap 표지
패키지 상세v2.1.1

sliver_snap

확장 및 축소된 바와 함께 강력한 스냅 슬리버를 사용할 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
7.7천
좋아요
104
Pub 점수
160

패키지 설치

flutter pub add sliver_snap

패키지 개요

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

SliverSnap은 개발자가 동적이고 스냅되는 슬리버를 만들고 확장 및 축소 가능한 헤더 바를 사용할 수 있도록 해주는 Flutter 패키지입니다. 전개된 상태와 접힌 상태 사이의 부드러운 전환을 가능하게 하여 스크롤 인터랙션을 향상시키며, 몰입형 앱 인터페이스를 구현하는 데 이상적입니다. 이 패키지는 CustomScrollView와 원활하게 통합되며 Android, iOS, Web, macOS, Windows, Linux 등 모든 주요 플랫폼을 지원합니다. 특히 파라락스 헤더와 상호작용 가능한 네비게이션 바와 같은 현대적인 UI 패턴을 구현하는 데 매우 유용합니다.

사용 사례

  • 인터랙티브 앱 헤더 만들기
  • 패러럴 스트롤링 효과 구현
  • 반응형 네비게이션 바 만들기
  • 몰입형 사용자 경험 설계
  • 스크롤 기반 애니메이션 개발
  • 콘텐츠 탐색 인터페이스 개선

주요 기능

  • 부드러운 스냅 동작
  • 확장 및 축소 상태 지원
  • CustomScrollView와의 원활한 통합
  • 크로스 플랫폼 호환성
  • 사용자 정의 가능한 스냅 포인트
  • 실시간 스크롤 피드백

적합한 대상

  • 현대의 Flutter 앱을 개발하는 개발자
  • 동적 헤더를 구현하는 UI 디자이너
  • 스크롤 기반 상호작용을 요구하는 앱
  • 복잡한 스크롤 레이아웃을 가진 프로젝트
  • 사용자 경험을 완성도 있게 다루는 팀

고려 사항

  • CustomScrollView에 대한 이해가 필요합니다
  • 큰 목록에 대한 성능 튜닝이 필요할 수 있습니다
  • 기본 사용법을 넘어서는 문서가 제한적
  • 간단한 정적 헤더에는 적합하지 않습니다
  • 고급 UI 컴포넌트에 가장 적합
  • 중첩 스크롤 시나리오에서의 잠재적 복잡성

원본 README

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

Sliver-Snap Banner Image

Sliver Snap

Platform Pub Package License: MIT

🚀 Sliver Snap is a Flutter package that simplifies the process of adding collapsible and expandable app bars to your app. It offers smooth transitions that respond seamlessly to user scrolling and snaps to the appropriate mode when the user stops scrolling midway. 💻 It's highly customizable and provides a user-friendly experience.
Say goodbye to manual implementation and make your Flutter app more interactive and intuitive with Sliver Snap. 🤯

Table of contents

Preview

basic Performance
Android Basic PPerformance image

Installing

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  sliver_snap: ^2.0.0

or you can add the latest version from the command line:

flutter pub add sliver_snap
2. Install it

You can install packages from the command line with Flutter:

$ flutter pub get
3. Import it

Now in your Dart code, you can use:

import 'package:sliver_snap/sliver_snap.dart';

Basic Usage

  SliverSnap(
    onCollapseStateChanged: (isCollapsed, scrollingOffset, maxExtent) {},
    collapsedBackgroundColor: Colors.black,
    expandedBackgroundColor: Colors.transparent,
    backdropWidget: Image.network(
      "https://picsum.photos/800/1200",
      fit: BoxFit.cover,
    ),
    bottom: const PreferredSize(
      preferredSize: Size.fromHeight(50),
      child: Icon(
        Icons.directions_boat,
        color: Colors.blue,
        size: 45,
      ),
    ),
    expandedContentHeight: 400,
    expandedContent: const Center(
      child: Icon(
        Icons.ac_unit_sharp,
        color: Colors.amber,
        size: 70,
      ),
    ),
    collapsedContent:
    const Icon(Icons.car_crash, color: Colors.green, size: 45),
    body: const Material(
      elevation: 7,
      child: Placeholder(),
    ),
  );
Properties
Property Type Default Value Description
expandedContent Widget N/A The content that is shown when expanded.
It is a required property.
collapsedContent Widget N/A The appbar Which is shown when collapsed.
It is a required property.
body Widget N/A The content shown below the appbar.
It is a required property.
pinned boolean true Whether the appbar will be fixed at the top of the scroll view.
For more information check the documentation For more information check the flutter docs.
collapsedBarHeight double 60.0 The height of the collapsedContent.
animationDuration Duration 300 milliseconds The duration of the scroll animation which happens when automatically snapping to the collapsed or the expanded widgets.
animationCurve Curve Curves.easeInOut The Curve of the scroll animation which happens when automatically snapping to the collapsed or the expanded widgets.
snap boolean false Whether the app bar behave in a smooth or a rigid way as the it is scrolling.
For more information check the documentation flutter docs.
floating boolean false Whether the app bar should become visible as soon as the user scrolls towards the app bar.
For more information check the flutter docs.
stretch boolean false Whether the app bar should stretch to fill the over-scroll area.
For more information check the flutter docs.
expandedContentHeight double? N/A The height of the expandedContent.
bottom PreferredSizeWidget? N/A The widget that appears across the bottom of the appbar. For example a TabBar.
This widget has to implement a PreferredSizeWidget.
automaticallyImplyLeading bool? false Provides Control of the AppBar's leading widget. When set to true, the framework will automatically add a leading widget
When set to false , no leading widget will be added automatically.
For more information check the flutter docs.
leading Widget? N/A The leading widget at the start both the expandedContent and the collapsedContent, typically an Icon or an IconButton. It can also be a BackButton.
actions List? N/A A list of action widgets to display in a row after the collapsedContent widget.
backdropWidget Widget? N/A The content that is shown below the appbar. In most cases it's just the page content.
expandedBackgroundColor Color? N/A The background Color of the expandedContent widget.
collapsedBackgroundColor Color? N/A The background Color of the collapsedContent widget.
scrollController ScrollController? N/A Can be used to pass your own scrollController to customize the appbar even more.
scrollBehavior ScrollBehaviour? N/A How the scrollable widgets behave, either Material or Cupertino Scrolling behaviors.
onCollapseStateChanged CollapsingStateCallback? N/A This is a callback function that is triggered when the bar is either collapsed or expanded. It can be used to customize the animation and behavior of the widget to better suit your needs.
elevation double 0.0 The elevation of the app bar
forceElevated bool false Whether to show the shadow appropriate for the elevation even if the content is not scrolled under the app bar. Defaults to false, meaning that the elevation is only applied when the app bar is being displayed over content that is scrolled under it.

Extra Components

The below are supplementary widgets that can help you build the appbar faster.

1. Collapsed AppBar Content widget

This can be used to create a custom collapsedContent widget. It has the following properties:

  1. leading: This is the leading widget specifically for the collapsedContent Appbar. Don't add the leading widget to the ExpandedContent widget or the SliverSnap widget, as they might overlap.
  2. title: The middle widget between the leading and the trailing of the collapsedContent Appbar.,
  3. trailing: The widget that is displayed at the rightmost part of the collapsedContent.
      CollapsedAppBarContent(
        leading: const Text('Leading Widget'),
        title: const Text('title'),
        trailing: SizedBox(
          height: 40,
          child: Image.network(
            'https://picsum.photos/800/1200',
            fit: BoxFit.cover,
          ),
        ),
      ),
2. Expanded Content widget

This can be used to create a custom expanded widget. It has the following properties:

  1. leading: This is the leading widget specifically for the expandedContent Appbar. Don't add the leading widget to the CollapsedAppBarContent widget or the SliverSnap widget, as they might overlap.
    ExpandedContent(
      leading: const Text('Leading Widget'),
      child: const Text('Expanded Content'),
    );

Additional information

Feel free to check the example for more usage info.

Bugs or Requests

If you encounter any problems feel free to open an issue. If you feel the library is missing a feature, please raise a ticket. Pull request are also welcome.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.