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

패키지 상세v0.4.1

super_sliver_list

크고 변수 범위를 가진 리스트를 처리할 수 있는 SliverList 및 ListView의 즉시 사용 가능한 대체품으로 특정 항목으로 점프하거나 애니메이션할 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
13만
좋아요
301
Pub 점수
150

패키지 설치

flutter pub add super_sliver_list

패키지 개요

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

SuperSliverList는 변수 항목 높이를 가진 대규모 목록을 효율적으로 관리하기 위해 설계된 SliverList 및 ListView의 고성능 대체품입니다. 부드러운 스크롤링, 항목으로 바로 이동하는 탐색 기능, 항목 간 애니메이션 전환을 지원합니다. Flutter의 커스텀 스크롤 뷰 시스템에 기반하여 구현되어 있으며, 보이는 위젯만 빌드함으로써 렌더링을 최적화하여 동적 또는 복잡한 목록 구조에 이상적입니다. 다양한 플랫폼에서 반응형이고 확장 가능한 목록 상호작용이 필요한 앱에 특히 유용합니다.

사용 사례

  • 변동하는 항목 크기와 함께 대규모 동적 목록
  • 특정 목록 항목으로 부드럽게 이동
  • 애니메이션 목록 전환
  • 복잡한 스크롤 가능한 인터페이스
  • 고성능 리스트 렌더링
  • 크로스 플랫폼 목록 컴포넌트

주요 기능

  • 변수 범위 지원
  • 항목으로 점프하고 애니메이션하기
  • 대규모 데이터셋을 위한 최적화 렌더링
  • SliverList/ListView의 즉시 대체품
  • 내장된 스크롤 위치 유지
  • 크로스 플랫폼 호환성

적합한 대상

  • 복잡한 스크롤 가능한 UI를 구축하는 개발자
  • 대규모 또는 동적 데이터 세트를 가진 앱
  • 성능 중심의 리스트 구현
  • 다중 플랫폼 Flutter 애플리케이션
  • 고급 리스트 탐색이 필요한 사용자

고려 사항

  • Sliver 기반 레이아웃에 대한 이해가 필요합니다
  • 매우 작은 목록의 경우 오버헤드가 발생할 수 있습니다
  • 원시 슬리버 위젯에 비해 사용자 정의가 제한적입니다
  • 자주 업데이트되는 스크롤 가능한 콘텐츠에 가장 적합
  • 정적이고 간단한 목록에는 권장되지 않습니다

원본 README

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

SliverList and ListView - Supercharged

See the live example of SuperSliverList.

SuperSliverList and SuperListView are drop in replacement widgets for SliverList and ListView with greatly improved performance and additional features:

Fast scrolling with large amount of items with variable extents

SliverList performance degrades heavily when quickly scrolling through a large amount of items with different extents, requiring workarounds such as using FixedExtentSliverList or prototype items. SuperSliverList uses different layout algorithm and can handle virtually unlimited number of items with variable extents without any slow-downs.

Ability to jump or animate to specific item

SliverList does not provide any way to jump or animate a particular index. There is a scrollable_positioned_list package that provides this functionality, but it comes at a cost, as it requires custom scroll view, does not seem to work properly with Scrollbars, can't be used with with other slivers (such as sticky headers) and ultimately is backed by a SliverList so it has the same performance issues as mentioned above.

SuperSliverList provides a way to reliably jump and animate to a specific item, even if the item is outside of the viewport and has not been built or laid out yet.

Smooth and predictable scrollbar behavior

SliverList is quite prone to scrollbar erraticaly jumping around when scrolling through a list of items with different extents. With SuperSliverList the scrollbar should behave more predictably. See the Advanced section for more details.

Basic Usage

SuperListView is a drop-in replacement for ListView, and as such you can use it same way you'd use ListView:

SuperListView.builder(
  itemCount: 1000,
  itemBuilder: (context, index) {
    return ListTile(title: Text('Item $index'));
  },
)

SuperSliverList is a drop-in replacement for SliverList and should work with any CustomScrollView configuration:

CustomScrollView(
  slivers: <Widget>[
    SliverPadding(
      padding: const EdgeInsets.all(20.0),
      sliver: SuperSliverList(
        delegate: SliverChildListDelegate(
          <Widget>[
            const Text("I'm dedicating every day to you"),
            const Text('Domestic life was never quite my style'),
            const Text('When you smile, you knock me out, I fall apart'),
            const Text('And I thought I was so smart'),
          ],
        ),
      ),
    ),
  ],
)

Jumping and animating to specific item

ListController can be provided to SuperSliverList/SuperListView and used to jump or animate to specific item:

class _MyState extends State<MyWidget> {
  final _listController = ListController();
  final _scrollController = ScrollController();

  @override
  Widget build(BuildContext context) {
    return SuperListView.builder(
      listController: _listController,
      controller: _scrollController,
      itemCount: 1000,
      itemBuilder: (context, index) {
        return ListTile(title: Text('Item $index'));
      },
    );
  }

  void jumpToItem(int index) {
    _listController.jumpToItem(
      index: index,
      scrollController: _scrollController,
      alignment: 0.5,
    );
  }

  void animateToItem(int index) {
    _listController.animateToItem(
      index: index,
      scrollController: _scrollController,
      alignment: 0.5,
      // You can provide duration and curve depending on the estimated
      // distance between currentPosition and the target item position.
      duration: (estimatedDistance) => Duration(milliseconds: 250),
      curve: (estimatedDistance) => Curves.easeInOut,
    );
  }
}

Advanced

Very roughtly speaking SuperSliverList works by estimating the extent of items that are outside of viewport and when these items are scrolled into the viewport cache area the scroll position is transparently adjusted to account of the difference between estimated and actual extents. On small lists this difference may result in scrollbar movement not being perfectly aligned with list movement. SuperSliverList provides two ways to rectify this:

Improve extent estimation

You can register custom callback that will be used to estimate extent of estimated items. This can be useful if you have an idea, atleast approximately, how large the extent of each item is.

SuperSliverList(
    delegate: /*...*/,
    estimateExtent: (index) => 100.0, // Provide your own extent estimation
)
Precalculate extents for items

SuperSliverList can, if needed, asynchronously precalculate extents for items. To enfore this, subclass ExtentPrecalculationPolicy and provide it to SuperSliverList:

In this example the extents are eagerly precalculated for lists with less than 100 items:

class MyPrecalculationPolicy extends ExtentPrecalculationPolicy {
  @override
  bool shouldPrecaculateExtents(ExtentPrecalculationContext context)  {
    return context.numberOfItems < 100;
  }
}

return SuperSliverList(
    delegate: /*...*/,
    extentPrecalculationPolicy: myPolicy,
)

The threshold is arbitrary, but in general there are diminishing returns for precalculating extents for large lists, as the extent estimation error for each item has much smaller impact on the scrollbar position if there are many items.

Example

See the example folder for a complete sample app using SuperSliverList. You can also see the example deployed live.

카테고리

의존성

의존성 목록 2 개

소스 저장소

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

순위