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

reorderable_grid_view 표지
패키지 상세v2.2.8

reorderable_grid_view

재정렬 가능한 그리드 뷰

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
5.4만
좋아요
164
Pub 점수
120

패키지 설치

flutter pub add reorderable_grid_view

패키지 개요

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

그리드 레이아웃 내 항목의 드래그 앤 드롭 재정렬을 가능하게 하는 플러터 패키지입니다. GridView의 기능을 확장하여 사용자가 제스처를 통해 타일을 직관적으로 재배치할 수 있도록 합니다. 커스터마이징 가능한 대시보드, 작업 보드 또는 동적 항목 위치가 필요한 모든 UI에 적합합니다. 모바일, 웹, 데스크톱을 포함한 모든 주요 플랫폼을 지원하며 장치 간 일관된 동작을 보장합니다. 성능과 통합 용이성을 고려해 설계되었으며 기존 플러터 애플리케이션에서 원활하게 작동합니다.

사용 사례

  • 사용자 정의 가능한 대시보드 레이아웃
  • 작업 관리 인터페이스
  • 사진 갤러리 재정렬
  • 사용자 선호도 기반 항목 정렬
  • 인터랙티브한 그리드 기반 설정

주요 기능

  • 드래그 앤 드롭 재정렬
  • 크로스 플랫폼 호환성
  • 기존 GridView와의 간단한 통합
  • 사용자 정의 드래그 핸들을 지원합니다
  • 부드러운 전환을 위한 내장 애니메이션

적합한 대상

  • 인터랙티브 그리드 UI를 구축하는 개발자
  • 사용자 중심 콘텐츠 배치가 필요한 앱
  • 동적 레이아웃 요구 사항을 가진 프로젝트

고려 사항

  • 상태 관리에 주의 깊게 대응해야 합니다
  • 매우 큰 데이터 세트에서는 성능에 영향을 줄 수 있습니다
  • 드래그 피드백에 대한 사용자 정의가 제한적
  • 매우 높은 주파수 업데이트에 최적화되지 않음

원본 README

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

ReorderableGridView

Idea from official ReorderableListView

Usage:

dependencies:
  reorderable_grid_view: ^2.2.9-alpha.4

Example

Sceenshot
class _MyHomePageState extends State<MyHomePage> {
  final data = [1, 2, 3, 4, 5];

  @override
  Widget build(BuildContext context) {
    Widget buildItem(String text) {
      return Card(
        key: ValueKey(text),
        child: Text(text),
      );
    }

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),

      body: Center(
        // use ReorderableGridView.count() when version >= 2.0.0
        // else use ReorderableGridView()
        child: ReorderableGridView.count(
          crossAxisSpacing: 10,
          mainAxisSpacing: 10,
          crossAxisCount: 3,
          children: this.data.map((e) => buildItem("$e")).toList(),
          onReorder: (oldIndex, newIndex) {
            setState(() {
              final element = data.removeAt(oldIndex);
              data.insert(newIndex, element);
            });
          },
          footer: [
            Card(
              child: Center(
                child: Icon(Icons.add),
              ),
            ),
          ],
        ),
      ),
    );
  }
}

Options

option desc
dragWidgetBuilderV2 the drag widget builder
restrictDragScope restrict drag scope to ReorderableGridView, not drag over the scree, default is false
dragStartDelay the longPress time
scrollDirection the scroll direction, default is Axis.vertical, supports Axis.horizontal
scrollSpeedController control how speed when scroll down when drag out of viewport
OnDropIndexChange the drop position changed, void (index, oldIndex), oldIndex = nil if is drag start.

dragWidgetBuilderV2

Normaly you can do like this:

dragWidgetBuilderV2: DragWidgetBuilderV2(
	isScreenshotDragWidget: false,
	builder: (index, child, screenshot) {
		return child;
	}
)
  • child is you dragging widget.

And if you dragging widget has some state, the callback's child can't access the state. So you can do a screenshot like this.

dragWidgetBuilderV2: DragWidgetBuilderV2(
	isScreenshotDragWidget: true,
	builder: (index, child, screenshot) {
		return Image(screenshot);
	}
)

Constructors

  • ReorderableGridView.builder
  • ReorderableGridView.count
  • ReorderableSliverGridView.count

custom reorderable

You can use ReorderableWrapperWidget to custom your reorderable. Use ReorderableWrapperWidget as root. and it's descendants is ReorderableItemView[] list

  • ReorderableWrapperWidget(child: SomeCollection(children: ReorderableItemView))

Important

  • the placeholderBuilder is not right when the list is very long, is not fixable for now. please see issue 47
  • can drag out of scope in ReorderableSliverGridView, please see issue 52

TODO

fix placeholderBuilder is not right when the list is very long

Other link project

If this project is not fit your meet, you can try those other projects

카테고리

소스 저장소

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