PagedDatatable은 내장된 정렬 및 필터링 기능을 갖춘 현대적인 방식으로 페이지 구분된 DataTable을 생성하는 데 사용되는 Flutter 패키지입니다. 데이터를 페이지 단위로 로드함으로써 대규모 데이터 세트를 효율적으로 처리하는 데이터 테이블 구현을 간소화합니다. 이 패키지는 Flutter의 위젯 시스템과 원활하게 통합되며, 페이지네이션, 컬럼 정렬, 동적 필터링 관리를 위한 깔끔한 API를 제공합니다. 구조화된 데이터를 사용자 친화적인 방식으로 표시하기 위해 강력하고 사용자 정의 가능한 솔루션을 찾는 개발자를 위한 것입니다.
사용 사례
웹 및 모바일 앱에서 대규모 데이터셋 표시
정렬 및 필터링 가능한 데이터 테이블 구현
구조화된 데이터를 사용하여 관리 대시보드 구축하기
분석을 위한 반응형 데이터 그리드 만들기
지연 로딩을 통한 사용자 경험 향상
검색 및 정렬 기능 통합
주요 기능
사용자 정의 페이지 크기와 함께 내장형 페이지네이션
오름차순/내림차순으로 열 정렬 지원
동적 필터링 기능
지연 렌더링을 통한 효율적인 데이터 로드
사용자 정의 가능한 테이블 스타일 및 레이아웃
기존 데이터 소스와의 간편한 통합
적합한 대상
데이터 중심 애플리케이션을 개발하는 개발자
재사용 가능한 테이블 컴포넌트가 필요한 프론트엔드 팀
효율적인 데이터 시각화가 필요한 프로젝트
UX 향상에 집중하는 플러터 개발자
관리자 또는 보고 인터페이스를 구현하는 팀
고려 사항
데이터 소스 통합을 위해 수동 설정이 필요합니다
제한된 플랫폼별 최적화
내장된 내보내기 기능 없음
복잡한 레이아웃의 경우 추가 스타일링이 필요할 수 있습니다
고급 사용 사례를 위해 외부 상태 관리에 의존
매우 높은 주파수 업데이트에 최적화되지 않음
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
PagedDataTable
Completely customisable data table which supports cursor and offset pagination, filters and horizontal scrolling out-of-the-box. It's written from scratch, no dependency from Flutter's DataTable nor Table.
Designed to follow Google's Material You style.
Everything you need is a PagedDataTable<K, T> widget, which accepts two generic arguments, K and T, the type of object you will use as paging key and the type of object you will be showing in the table.
Keep in mind that K must extends Comparable.
There are only two required parameters: columns and fetcher.
The fetcher is a function that gets called every time a page is requested. It gives you the current page size, sort and filter models and the page token that is requested. It must return
a FutureOr<(List<T>, K?)>, so you can convert it to a Future and do async-like requests or simply return the data.
It expects a tuple, where the first value is the list of items and the second the next page token:
By default, PagedDataTable does not copy the returned list, so, if it is a shared list, you or the table may modify the items. If you want, PagedDataTable can copy the list
if you specify it in the configuration property:
The header renders the column names, but also the FilterBar exists, which is an additional header that renders the filter picker and, optionally, you can display additional widgets aligned at the right of the bar.
Just pass your widget to the filterBarChild property. Naturally you would want to display a PopupMenuButton that will act as a menu.
Footer
Using the footer property you can render anything. If you don't pass it, it will render the DefaultFooter widget,
which again, if not specified, will display, aligned to the right, the following widgets:
Refresh button: A button that can be used to refresh the current dataset.
Page size selector: A dropdown that can be used to select the current page size to use, based on the pageSizes property.
Current page display: Displays the current page number.
Navigation buttons: will display the previous and next buttons as IconButtons.
Custom footer
If you want your own footer widget but reuse some of the already existing widgets, they are named: RefreshButton, PageSizeSelector, CurrentPage and NavigationButtons.
Columns
There are two types of columns in PagedDataTable:
ReadOnlyTableColumn<K, T>: renders a simple widget that does not allow edition.
EditableTableColumn<K, T, V>: renders a simple widget too, but this can be modified in place and modify the dataset.
K and T are the same parameters defined in the PagedDataTable widget.
Every column type has:
title: the column's title. It is a widget but commonly it's a Text widget displaying the name.
size: configures the column's size. By default, it is a FractionalColumnSize(.1), which means it will take 10% of the available width. You can use FixedColumnSize, FractionalColumnSize, RemainingColumnSize and MaxColumnSize.
format: applies a transformation to the cell's widget. You have NumericColumnFormat, which aligns content to the right and AlignColumnFormat which aligns cell's content to the alignment property and you can implement your own implemeting the ColumnFormat interface.
sort and id: both properties are used to indicate that a column can be used for sorting. The id is what you get in the Fetcher's SortModel. To sort, you click the column's header.
There are other properties that you can use to play around and modify your columns. Check out the ReadOnlyTableColumn's documentation.
If you want to fix columns at the left, you can specify the amount of columns to fix using the fixedColumnCount property.
TableColumn<K, T>
Is the default ReadOnlyTableColumn that renders a cell using the cellBuilder property.
This abstract class provides two more properties, getter and setter. The first one is used to provide the value V to render and the second one
is the function used to set the new value. It must return a boolean indicating if the operation succeeded or not. If is true, the cell will update its
value, otherwise will keep the old one.
There are three built in editable columns, which are DropdownTableColumn which renders a dropdown; TextTableColumn which renders a Text until double-clicked, then it renders a TextField used to edit the cell's content; LargeTextTableColumn, which is the same as TextTableColumn but when
double-clicked, it opens an overlay, designed to edit large text cells.
To create your own columns, simply extend ReadOnlyTableColumn or EditableTableColumn depending on your needs.
For example:
classMyColumnType<K, T> extendsReadOnlyTableColumn<K, T> {
@overrideWidgetbuild(BuildContext context, T item, int index) {
returnMyCellWidget();
}
}
If you want more examples, check out the implementation of the already existing column types.
Filters
PagedDataTable allows you to define a set of filters that you can use to interactively select them using a
popup overlay or a bottom sheet if you are in a small device.
TextTableFilter: renders a TextField to filter by raw text.
DropdownTableFilter: renders a DropdownButton with a set of options.
DateTimePickerTableFilter: renders a TextField that, when tapped, opens the DateTime picker dialog.
DateRangePickerTableFilter: the same as DateTimePickerTableFilter but selects a DateTimeRange.
ProgrammingTextFilter: a filter that does not render nothing in the filter dialog but can be set using the controller.
Every filter type must define, at least, the id, the name and the chipFormatter properties. The first one is the identifier of the filter, used in the fetcher's FilterMode property. The name is the label displayed in the filter picker and the chipFormatter is a function that maps the actual selected value to a more user-friendly string that is displayed in the selected filter's chip.
Custom filters
To create your own filter, extend the TableFilter<T> abstract class, where T is the type of value the filter will handle. Then, implement the buildPicker function, which renders the actual filter picker.
The implementation of the TextTableFilter as an example:
If you want to control the table programatically, provide your own PagedDataTableController<K, V> instance passing it to the controller property. It provides methods to interact with rows (selecting, unselecting, removing, inserting, updating), filters, sorting, pagination, and more.
Internationalization
Update your MaterialApp or CupertinoApp widget with the following: