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

json_table 표지
패키지 상세v2.0.1

json_table

json(Map)에서 직접 테이블을 표시할 수 있는 Json 테이블 위젯을 제공하는 플러터 패키지입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
4.9천
좋아요
237
Pub 점수
130

패키지 설치

flutter pub add json_table

패키지 개요

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

json_table 패키지는 JSON(Map) 구조에서 직접 표 형식 데이터를 렌더링할 수 있는 Flutter 위젯입니다. 수동적인 위젯 조합 없이도 깔끔하고 읽기 쉬운 테이블 형식으로 구조화된 데이터를 표시하는 과정을 단순화합니다. 디버깅, 데이터 시각화 또는 API 응답 표시에 적합하며, 동적 콘텐츠를 지원하고 모든 주요 플랫폼과 원활하게 통합됩니다. 이 패키지는 가볍고 사용하기 쉬워 JSON 소스에서 빠르게 테이블을 렌더링하려는 개발자에게 적합합니다.

사용 사례

  • API 응답 데이터 표시
  • JSON 구조 디버깅
  • 간단한 데이터 대시보드 만들기
  • 렌더링 구성 파일
  • 중첩된 JSON 객체 제시
  • 관리 패널 구축

주요 기능

  • 직접 JSON을 테이블로 변환
  • 중첩된 맵과 리스트를 지원합니다
  • 다중 플랫폼에 걸친 반응형 레이아웃
  • 사용자 정의 스타일 옵션
  • 최소한의 보일러플레이트 코드
  • 내장 열 자동 감지

적합한 대상

  • 빠른 테이블 렌더링이 필요한 개발자
  • JSON API를 사용하는 프론트엔드 팀
  • 데이터 형식을 보여주는 교육용 앱
  • 동적 데이터를 사용한 UI 프로토타이핑
  • 디버그 친화적인 데이터 뷰가 필요한 앱

고려 사항

  • 정렬 또는 필터링과 같은 제한된 고급 테이블 기능
  • 매우 큰 데이터 세트에 최적화되지 않음
  • 스타일 맞춤 설정을 위해서는 Flutter 위젯에 대한 이해가 필요합니다
  • 정적 또는 반정적 데이터 표시에 가장 적합
  • 복잡한 데이터 변환을 위해 추가적인 로직이 필요할 수 있습니다

원본 README

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

Json Table Widget GitHub stars Twitter Follow GitHub last commit Website shields.ioOpen Source Love

Join us on Discord: https://discord.gg/7byeCn7MGF

💙 Proudly Sponsored by FieldAssist


Request a Demo

This Flutter package provides a Json Table Widget for directly showing table from a json(Map). Supports Column toggle also.

Live Demo: https://apgapg.github.io/json_table/

Live Data Testing: https://apgapg.github.io/json_table/#/customData

Features
  • The table constructed isn't the flutter's native DataTable.
  • The table is manually coded hence serves a great learning purpose on how to create simple tables manually in flutter
  • Supports vertical & horizontal scroll
  • Supports custom columns includes default value, column name, value builder
  • Supports nested data showing
  • Supports pagination
  • Supports row select color, callback

JsonTable JsonTable JsonTable JsonTable JsonTable JsonTable

💻 Installation

In the dependencies: section of your pubspec.yaml, add the following line:

Version

dependencies:
  json_table: <latest version>

❔ Usage

Import this class
import 'package:json_table/json_table.dart';
- Vanilla Implementation
//Decode your json string
final String jsonSample='[{"id":1},{"id":2}]';
var json = jsonDecode(jsonSample);

//Simply pass this json to JsonTable
child: JsonTable(json)
- Implementation with HEADER and CELL widget builders
JsonTable(
   json,
   tableHeaderBuilder: (String header) {
     return Container(
       padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0),
       decoration: BoxDecoration(border: Border.all(width: 0.5),color: Colors.grey[300]),
       child: Text(
         header,
         textAlign: TextAlign.center,
         style: Theme.of(context).textTheme.display1.copyWith(fontWeight: FontWeight.w700, fontSize: 14.0,color: Colors.black87),
       ),
     );
   },
   tableCellBuilder: (value) {
     return Container(
       padding: EdgeInsets.symmetric(horizontal: 4.0, vertical: 2.0),
       decoration: BoxDecoration(border: Border.all(width: 0.5, color: Colors.grey.withOpacity(0.5))),
       child: Text(
         value,
         textAlign: TextAlign.center,
         style: Theme.of(context).textTheme.display1.copyWith(fontSize: 14.0, color: Colors.grey[900]),
       ),
     );
   },
 )

Head over to example code: simple_table.dart

- Implementation with custom COLUMNS list
  • Pass custom column list to control what columns are displayed in table
  • The list item must be constructed using JsonTableColumn class
  • JsonTableColumn provides 4 parameters, namely,
JsonTableColumn("age", label: "Eligible to Vote", valueBuilder: eligibleToVote, defaultValue:"NA")
  • First parameter is the field/key to pick from the data
  • label: The column header label to be displayed
  • defaultValue: To be used when data or key is null
  • valueBuilder: To get the formatted value like date etc
JsonTable
//Decode your json string
final String jsonSample='[{"name":"Ram","email":"ram@gmail.com","age":23,"DOB":"1990-12-01"},'
                              '{"name":"Shyam","email":"shyam23@gmail.com","age":18,"DOB":"1995-07-01"},'
                              '{"name":"John","email":"john@gmail.com","age":10,"DOB":"2000-02-24"},'
                              '{"name":"Ram","age":12,"DOB":"2000-02-01"}]';
var json = jsonDecode(jsonSample);
//Create your column list
var columns = [
      JsonTableColumn("name", label: "Name"),
      JsonTableColumn("age", label: "Age"),
      JsonTableColumn("DOB", label: "Date of Birth", valueBuilder: formatDOB),
      JsonTableColumn("age", label: "Eligible to Vote", valueBuilder: eligibleToVote),
      JsonTableColumn("email", label: "E-mail", defaultValue: "NA"),
    ];
//Simply pass this column list to JsonTable
child: JsonTable(json,columns: columns)

//Example of valueBuilder
String eligibleToVote(value) {
    if (value >= 18) {
      return "Yes";
    } else
      return "No";
}

Head over to example code: custom_column_table.dart

- Implementation with nested data list

Suppose your json object has nested data like email as shown below:

{"name":"Ram","email":{"1":"ram@gmail.com"},"age":23,"DOB":"1990-12-01"}
  • Just use email.1 instead of email as key
JsonTableColumn("email.1", label: "Email", defaultValue:"NA")
JsonTable
//Decode your json string
final String jsonSample='[{"name":"Ram","email":{"1":"ram@gmail.com"},"age":23,"DOB":"1990-12-01"},'
                               '{"name":"Shyam","email":{"1":"shyam23@gmail.com"},"age":18,"DOB":"1995-07-01"},'
                               '{"name":"John","email":{"1":"john@gmail.com"},"age":10,"DOB":"2000-02-24"}]';
var json = jsonDecode(jsonSample);
//Create your column list
var columns = [
      JsonTableColumn("name", label: "Name"),
      JsonTableColumn("age", label: "Age"),
      JsonTableColumn("DOB", label: "Date of Birth", valueBuilder: formatDOB),
      JsonTableColumn("age", label: "Eligible to Vote", valueBuilder: eligibleToVote),
      JsonTableColumn("email.1", label: "E-mail", defaultValue: "NA"),
    ];
//Simply pass this column list to JsonTable
child: JsonTable(json,columns: columns)

Head over to example code: custom_column_nested_table.dart

Column toggle

Option for toggling column(s) also. User can customise which columns are to be shown

 showColumnToggle: true
JsonTable
Row Highlighting

Add row highlighting with custom color support

JsonTable
allowRowHighlight: true,
rowHighlightColor: Colors.yellow[500].withOpacity(0.7),
Row Select Callback

Get the index and data map of a particular selected row. Note index might return incorrect value in case of pagination

onRowSelect: (index, map) {
    print(index);
    print(map);
  },
Pagination

Just provide an int value to paginationRowCount parameter

JsonTable
paginationRowCount: 4,

TODO

  • [X] Custom header list parameter. This will help to show only those keys as mentioned in header list
  • [X] Add support for keys missing in json object
  • [X] Add support for auto formatting of date
  • [X] Extracting column headers logic must be change. Not to depend on first object
  • [X] Nested data showing support
  • [X] Row highlight support
  • [X] Row select callback
  • [X] Wrap filters in expansion tile
  • [X] Pagination support
  • [ ] Add option to change header row to vertical row on left

⭐ My Flutter Packages

  • pie_chart GitHub stars Flutter Pie Chart with cool animation.
  • avatar_glow GitHub stars Flutter Avatar Glow Widget with glowing animation.
  • search_widget GitHub stars Flutter Search Widget for selecting an option from list.
  • animating_location_pin GitHub stars Flutter Animating Location Pin Widget providing Animating Location Pin Widget which can be used while fetching device location.

⭐ My Flutter Apps

👍 Contribution

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

카테고리

소스 저장소

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