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

extended_sliver 표지
패키지 상세v2.1.3

extended_sliver

Sliver의 강력한 확장 라이브러리로, SliverPinnedPersistentHeader, SliverPinnedToBoxAdapter 및 ExtendedSliverAppbar를 포함합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.4만
좋아요
163
Pub 점수
150

패키지 설치

flutter pub add extended_sliver

패키지 개요

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

ExtendedSliver는 추가적인 사용자 정의 가능한 컴포넌트로 Sliver 위젯 가족을 강화하는 Flutter 패키지입니다. 스크롤 중에도 고정되는 헤더를 위한 SliverPinnedPersistentHeader, 스크롤 가능한 영역 내에서 어떤 위젯이라도 고정할 수 있는 SliverPinnedToBoxAdapter, 그리고 고급 앱바 기능을 제공하는 ExtendedSliverAppbar를 도입합니다. 복잡한 목록과 앱바에서 스크롤 동작에 대한 세밀한 제어를 원하는 개발자를 위해 설계되었으며, 최소한의 보일러플레이트로 표준 Sliver의 기능을 확장합니다. 여러 플랫폼에서 고도화된 스크롤 경험을 필요로 하는 앱에 이상적입니다.

사용 사례

  • 스크롤 뷰 내 사용자 지정 가능한 지속 헤더
  • 동적 동작을 갖춘 고급 앱 바 디자인
  • 스크롤 가능한 목록에서 특정 위치에 위젯 고정
  • 복잡한 스크롤 기반 레이아웃 만들기
  • 계층적 스크롤 효과를 사용하여 반응형 UI 만들기
  • 최적화된 슬리버 사용을 통한 목록 성능 향상

주요 기능

  • 스리버핀드퍼시스턴트헤더는 스틱 헤더용입니다
  • 임의의 위젯을 고정하는 SliverPinnedToBoxAdapter
  • 개선된 사용자 정의 기능을 갖춘 ExtendedSliverAppbar
  • 모든 주요 플랫폼 지원
  • 최소 설정과 직관적인 API
  • 대규모 목록을 위한 최적화된 성능

적합한 대상

  • 복잡한 스크롤 가능한 인터페이스를 구축하는 개발자
  • 스크롤 동작에 정밀한 제어가 필요한 UI 디자이너
  • 동적 또는 계층적 콘텐츠 레이아웃을 가진 앱
  • 크로스 플랫폼 플러터 애플리케이션
  • 사용자 정의 스크롤 로직을 줄이려는 팀
  • 재사용 가능하고 유지보수가 가능한 슬리버 컴포넌트가 필요한 프로젝트

고려 사항

  • Sliver 위젯에 익숙해야 합니다
  • 간단한 스크롤 뷰의 복잡성을 증가시킬 수 있습니다
  • 고급 사용 사례에 가장 적합
  • 기본 예제 외에 문서가 제한적
  • 과도하게 사용할 경우 성능에 영향을 줄 수 있음
  • Flutter 기본 사항을 배우는 초보자에게 적합하지 않습니다

원본 README

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

extended_sliver

pub package GitHub stars GitHub forks GitHub license GitHub issues FlutterCandies QQ 群

Language: English | 中文简体

Description

A powerful extension library of Sliver, which include SliverToNestedScrollBoxAdapter, SliverPinnedPersistentHeader, SliverPinnedToBoxAdapter and ExtendedSliverAppbar.

Usage

Add packages to dependencies

Add the package to pubspec.yaml under dependencies.

dependencies:
  extended_sliver: latest-version

Download with flutter packages get

SliverPinnedPersistentHeader

It's the same as SliverPersistentHeader(pinned: true), but you don't have to force values of minExtent and maxExtent.

It provides minExtentProtoType and maxExtentProtoType to calculate minExtent and maxExtent automatically.

It's useful that you don't know the final extent before the widgets are laid out.

    SliverPinnedPersistentHeader(
      delegate: MySliverPinnedPersistentHeaderDelegate(
        minExtentProtoType: Container(
          height: 120.0,
          color: Colors.red.withOpacity(0.5),
          child: FlatButton(
            child: const Text('minProtoType'),
            onPressed: () {
              print('minProtoType');
            },
          ),
          alignment: Alignment.topCenter,
        ),
        maxExtentProtoType: Container(
          height: 200.0,
          color: Colors.blue,
          child: FlatButton(
            child: const Text('maxProtoType'),
            onPressed: () {
              print('maxProtoType');
            },
          ),
          alignment: Alignment.bottomCenter,
        ),
      ),
    )

SliverPinnedToBoxAdapter

You can create a pinned Sliver easily with it.

It's useful that you don't know the final extent before the child are laid out.

    SliverPinnedToBoxAdapter(
      child: Container(
        padding: const EdgeInsets.all(20),
        color: Colors.blue.withOpacity(0.5),
        child: Column(
          children: <Widget>[
            const Text(
                '[love]Extended text help you to build rich text quickly. any special text you will have with extended text. '
                '\n\nIt\'s my pleasure to invite you to join \$FlutterCandies\$ if you want to improve flutter .[love]'
                '\n\nif you meet any problem, please let me konw @zmtzawqlp .[sun_glasses]'),
            FlatButton(
              child: const Text('I\'m button. click me!'),
              onPressed: () {
                debugPrint('click');
              },
            ),
          ],
        ),
      ),
    )

ExtendedSliverAppbar

You can create SliverAppbar with out force the expandedHeight.

return CustomScrollView(
  slivers: <Widget>[
    ExtendedSliverAppbar(
      title: const Text(
        'ExtendedSliverAppbar',
        style: TextStyle(color: Colors.white),
      ),
      leading: const BackButton(
        onPressed: null,
        color: Colors.white,
      ),
      background: Image.asset(
        'assets/cypridina.jpeg',
        fit: BoxFit.cover,
      ),
      actions: Padding(
        padding: const EdgeInsets.all(10.0),
        child: Icon(
          Icons.more_horiz,
          color: Colors.white,
        ),
      ),
    ),
  ],
);

SliverToNestedScrollBoxAdapter

You can create nested scrollable widget(like Webview) in CustomScrollView/NestedScrollView.

return CustomScrollView(
  slivers: <Widget>[
      SliverToBoxAdapter(
        child: Container(
          height: 100,
          color: Colors.red,
          child: const Center(
            child: Text(
              'Header',
              style: TextStyle(color: Colors.white),
            ),
          ),
        ),
      ),
    ValueListenableBuilder<double>(
      valueListenable: nestedWebviewController.scrollHeightNotifier,
      builder: (
        BuildContext context,
        double scrollHeight,
        Widget? child,
      ) {
        return SliverToNestedScrollBoxAdapter(
          childExtent: scrollHeight,
          onScrollOffsetChanged: (double scrollOffset) {
            double y = scrollOffset;
            if (Platform.isAndroid) {
              // https://github.com/flutter/flutter/issues/75841
              y *= window.devicePixelRatio;
      
            nestedWebviewController.webviewController
                ?.scrollTo(0, y.ceil());
          },
          child: child,
        );
      },
      child: WebView(
        initialUrl: nestedWebviewController.initialUrl,
        onPageStarted: nestedWebviewController.onPageStarted,
        onPageFinished: nestedWebviewController.onPageFinished,
        onWebResourceError:
            nestedWebviewController.onWebResourceError,
        onWebViewCreated: nestedWebviewController.onWebViewCreated,
        onProgress: nestedWebviewController.onProgress,
        javascriptChannels: <JavascriptChannel>{
          nestedWebviewController
              .scrollHeightNotifierJavascriptChannel
        },
        javascriptMode: JavascriptMode.unrestricted,
      ),
    ),
    SliverToBoxAdapter(
        child: Container(
          height: 300,
          color: Colors.green,
          child: const Center(
            child: Text(
              'Footer',
              style: TextStyle(color: Colors.white),
            ),
          ),
        ),
    ),
  ],
);

Complex Demo

Complex Demo

image

카테고리

소스 저장소

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