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

animated_list_plus 표지
패키지 상세v0.5.2

animated_list_plus

두 목록 간의 변경 사항을 암시적으로 애니메이션하는 Flutter ListView이며, 항목 재정렬도 지원합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
3.5만
좋아요
198
Pub 점수
150

패키지 설치

flutter pub add animated_list_plus

패키지 개요

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

AnimatedListPlus는 리스트 항목 추가, 삭제 및 재정렬 시 부드러운 전환을 포함하여 리스트 변경 시 애니메이션을 제공하는 Flutter 패키지입니다. 내장된 애니메이션 지원으로 동적 리스트 구현을 간소화하고, 다양한 플랫폼에서 유연한 사용자 경험을 보장합니다. 이 패키지는 주요 Flutter 플랫폼을 모두 지원하며, 최소한의 설정으로 기존 프로젝트에 쉽게 통합할 수 있습니다. 수동 애니메이션 컨트롤러 없이도 자동으로 애니메이션 상태를 처리하여 리스트 상호작용을 향상시킵니다.

사용 사례

  • 시각적 피드백을 제공하는 동적 목록 업데이트
  • 양식 또는 작업 관리자에서 재정렬 가능한 항목 목록
  • 채팅 또는 피드 인터페이스에서의 부드러운 전환
  • 인터랙티브 할 일 목록 애플리케이션
  • 대시보드에서 실시간 데이터 표시

주요 기능

  • 리스트 변경에 대한 암시적 애니메이션
  • 항목 재정렬을 위한 내장 지원
  • 크로스 플랫폼 호환성
  • 최소한의 보일러플레이트 코드
  • 자동 애니메이션 상태 관리
  • 사용자 정의 가능한 애니메이션 곡선

적합한 대상

  • 인터랙티브한 리스트 기반 UI를 구축하는 개발자
  • 실시간 목록 업데이트가 필요한 앱
  • 부드러운 UX 전환을 강조하는 프로젝트
  • 애니메이션 복잡성을 줄이고자 하는 팀
  • Flutter 초보자가 고급 목록 기능 탐색 중

고려 사항

  • 매우 큰 목록에서는 성능에 영향을 줄 수 있습니다
  • 항목 키를 주의 깊게 다뤄야 합니다
  • 복잡한 애니메이션 로직에 대한 사용자 정의가 제한적
  • 매우 사용자 정의된 애니메이션 시퀀스에는 적합하지 않음
  • 중간 규모의 데이터 세트에 가장 적합

원본 README

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

Animated List Plus

Resurrection of the discontinued implicitly_animated_reorderable_list Plugin.

A Flutter ListView that implicitly calculates the changes between two lists using the MyersDiff algorithm and animates between them for you. The ImplicitlyAnimatedReorderableList adds reordering support to its items with fully custom animations.

Demo

Click here to view the full example.

Installing

Add it to your pubspec.yaml file:

dependencies:
  animated_list_plus: ^0.4.3

Install packages from the command line

flutter packages get

If you like this package, consider supporting it by giving it a star on GitHub and a like on pub.dev :heart:

Usage

The package contains two ListViews: ImplicitlyAnimatedList which is the base class and offers implicit animation for item insertions, removals as well as updates, and ImplicitlyAnimatedReorderableList which extends the ImplicitlyAnimatedList and adds reordering support to its items. See examples below on how to use them.

ImplicitlyAnimatedList

ImplicitlyAnimatedList is based on AnimatedList and uses the MyersDiff algorithm to calculate the difference between two lists and calls insertItem and removeItem on the AnimatedListState for you.

Example
// Specify the generic type of the data in the list.
ImplicitlyAnimatedList<MyGenericType>(
  // The current items in the list.
  items: items,
  // Called by the DiffUtil to decide whether two object represent the same item.
  // For example, if your items have unique ids, this method should check their id equality.
  areItemsTheSame: (a, b) => a.id == b.id,
  // Called, as needed, to build list item widgets.
  // List items are only built when they're scrolled into view.
  itemBuilder: (context, animation, item, index) {
    // Specifiy a transition to be used by the ImplicitlyAnimatedList.
    // See the Transitions section on how to import this transition.
    return SizeFadeTransition(
      sizeFraction: 0.7,
      curve: Curves.easeInOut,
      animation: animation,
      child: Text(item.name),
    );
  },
  // An optional builder when an item was removed from the list.
  // If not specified, the List uses the itemBuilder with
  // the animation reversed.
  removeItemBuilder: (context, animation, oldItem) {
    return FadeTransition(
      opacity: animation,
      child: Text(oldItem.name),
    );
  },
);

If you have a CustomScrollView you can use the SliverImplicitlyAnimatedList.

As AnimatedList doesn't support item moves, a move is handled by removing the item from the old index and inserting it at the new index.

ImplicitlyAnimatedReorderableList

ImplicitlyAnimatedReorderableList is based on ImplicitlyAnimatedList and adds reordering support to the list.

Example
ImplicitlyAnimatedReorderableList<MyGenericType>(
  items: items,
  areItemsTheSame: (oldItem, newItem) => oldItem.id == newItem.id,
  onReorderFinished: (item, from, to, newItems) {
    // Remember to update the underlying data when the list has been
    // reordered.
    setState(() {
      items
        ..clear()
        ..addAll(newItems);
    });
  },
  itemBuilder: (context, itemAnimation, item, index) {
    // Each item must be wrapped in a Reorderable widget.
    return Reorderable(
      // Each item must have an unique key.
      key: ValueKey(item),
      // The animation of the Reorderable builder can be used to
      // change to appearance of the item between dragged and normal
      // state. For example to add elevation when the item is being dragged.
      // This is not to be confused with the animation of the itemBuilder.
      // Implicit animations (like AnimatedContainer) are sadly not yet supported.
      builder: (context, dragAnimation, inDrag) {
        final t = dragAnimation.value;
        final elevation = lerpDouble(0, 8, t);
        final color = Color.lerp(Colors.white, Colors.white.withOpacity(0.8), t);

        return SizeFadeTransition(
          sizeFraction: 0.7,
          curve: Curves.easeInOut,
          animation: itemAnimation,
          child: Material(
            color: color,
            elevation: elevation,
            type: MaterialType.transparency,
            child: ListTile(
              title: Text(item.name),
              // The child of a Handle can initialize a drag/reorder.
              // This could for example be an Icon or the whole item itself. You can
              // use the delay parameter to specify the duration for how long a pointer
              // must press the child, until it can be dragged.
              trailing: Handle(
                delay: const Duration(milliseconds: 100),
                child: Icon(
                  Icons.list,
                  color: Colors.grey,
                ),
              ),
            ),
          ),
        );
      },
    );
  },
  // Since version 0.2.0 you can also display a widget
  // before the reorderable items...
  header: Container(
    height: 200,
    color: Colors.red,
  ),
  // ...and after. Note that this feature - as the list itself - is still in beta!
  footer: Container(
    height: 200,
    color: Colors.green,
  ),
  // If you want to use headers or footers, you should set shrinkWrap to true
  shrinkWrap: true,
);

For a more in depth example click here.

Transitions

You can use some custom transitions (such as the SizeFadeTransition) for item animations by importing the transitions pack:

import 'package:implicitly_animated_reorderable_list/transitions.dart';

If you want to contribute your own custom transitions, feel free to make a pull request.

Caveats

Note that this package is still in its very early phase and not enough testing has been done to guarantee stability.

Also note that computing the diff between two very large lists may take a significant amount of time (the computation is done on a background isolate though unless spawnIsolate is set to false).

Acknowledgements

The diff algorithm that ImplicitlyAnimatedList uses was written by Dawid Bota at GitLab.

카테고리

의존성

의존성 목록 2 개

소스 저장소

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