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

cr_json_widget 표지
패키지 상세v1.1.1

cr_json_widget

노드가 임의의 위젯일 수 있는 트리 구조를 시각화하는 위젯입니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.3천
좋아요
21
Pub 점수
150

패키지 설치

flutter pub add cr_json_widget

패키지 개요

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

cr_json_widget은 각 노드가 임의의 사용자 정의 위젯이 될 수 있는 계층적 트리 구조를 표시하는 Flutter 패키지입니다. 개발자가 JSON 데이터나 중첩된 구조를 상호작용 가능하고 사용자 정의 가능한 방식으로 시각화할 수 있도록 합니다. 노드의 동적 확장 및 축소를 지원하여 디버깅, 구성 보기 또는 데이터 탐색 인터페이스에 적합합니다. 크로스플랫폼 사용을 위해 설계되어 Android, iOS, Web, macOS, Windows, Linux에서 원활하게 작동합니다. 유연한 아키텍처로 다양한 데이터 소스와 UI 컴포넌트와의 통합이 가능합니다.

사용 사례

  • 중첩된 JSON 데이터 시각화
  • 복잡한 데이터 구조 디버깅
  • 인터랙티브 구성 패널
  • 데이터 탐색 인터페이스
  • 사용자 정의 트리 기반 UI

주요 기능

  • 노드로 어떤 위젯도 지원
  • 동적 확장/접기 가능한 노드
  • 크로스 플랫폼 호환성
  • 사용자 정의 가능한 트리 스타일
  • JSON 데이터와의 간편한 통합
  • 사용자 정의 렌더링을 위한 확장 가능

적합한 대상

  • 디버그 도구를 개발하는 개발자
  • 데이터 시각화를 만드는 UI 디자이너
  • 계층적 데이터 표시가 필요한 앱
  • 다중 플랫폼 프로젝트에 종사하는 팀
  • 중첩 구성 데이터를 포함하는 프로젝트

고려 사항

  • 매우 큰 트리에서는 성능에 영향을 줄 수 있습니다
  • 동적 업데이트를 위해 신중한 상태 관리가 필요합니다
  • 사용자 정의 노드 위젯은 레이아웃 제약 조건을 처리해야 합니다
  • 제한된 내장 편집 기능
  • 읽기 전용 또는 간단한 상호작용 시나리오에 가장 적합

원본 README

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

cr_json_widget

This widget visualises a tree structure, where a node can be any widget.

Examples

Getting Started

  1. Add plugin to your project:
    dependencies:
        cr_json_widget: ^1.1.0
    

Usage

CrJsonWidget
This widget display all children as simple ListView and that it does not have good performance with huge jsons.
  1. Create JsonController:

    final _jsonController = JsonController(
        allNodesExpanded: false,
        uncovered: 3,
    );
    

    allNodesExpanded - Sets whether the json tree is expanded by default

    uncovered - Sets the value to what nesting by default the json tree will be expanded

  2. Add widget: 2.1 Accepts json as Map <String, Any> and builds the tree automatically:

        ...
        final data = <String, dynamic>{
            'integer': 1, 
            'string': 'test', 
        }
        ...
        CrJsonWidget(
            ..
            json: data
        )
        ...
    

    2.2 Accepts your custom List , for placement in the form of a tree:

        CrJsonWidget(
            ..
        jsonNodes: [
            JsonNode(
                content: const Text(
                    'root1',
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Colors.red,
                    ),
                ),
            ),
            JsonNode(
                content: const Text(
                    'root2',
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Colors.deepPurpleAccent,
                    ),
                ),
                children: [
                    JsonNode(
                        content: const Text('child21'),
                    ),
                    JsonNode(
                        content: const Text('child22'),
                    ),
                    JsonNode(
                        content: const Text('root23'),
                        children: [
                            JsonNode(
                                content: const Text('child231'),
                            ),
                        ],
                        ),
                    ],
                ),
            ],
        ),
    

Full implementation example:

    ...
    CrJsonWidget(
        iconOpened: Icon(
            Icons.arrow_drop_down,
            size: _iconSize,
        ),
        iconClosed: Icon(
            Icons.arrow_right,
            size: _iconSize,
        ),
        indentHeight: 5,
        indentLeftEndJsonNode: _iconSize,
        jsonNodes: [
            JsonNode(
                content: const Text(
                    'root1',
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Colors.red,
                    ),
                ),
            ),
            JsonNode(
                content: const Text(
                    'root2',
                    style: TextStyle(
                        fontWeight: FontWeight.bold,
                        color: Colors.deepPurpleAccent,
                    ),
                ),
                children: [
                    JsonNode(
                        content: const Text('child21'),
                    ),
                    JsonNode(
                        content: const Text('child22'),
                    ),
                    JsonNode(
                        content: const Text('root23'),
                        children: [
                            JsonNode(
                                content: const Text('child231'),
                            ),
                        ],
                        ),
                    ],
                ),
            ],
        jsonController: _jsonController,
    ),

iconOpened - Custom icon for opening a node

iconClosed - Custom icon for closing a node

indentHeight - Vertical indent between levels

indentWidth - Horizontal indent between levels

indentLeftEndJsonNode - The starting position of the ending node (Recommended size is the size of the icon)

json - Parsed json

jsonNodes - List of root level json nodes

jsonController - Json controller to manage the json state

Json Recycler Widgets
Use these widgets, if you have huge jsons. Since these widgets have builders, huge jsons don't affect its performance in any way.
  1. Create JsonRecyclerController:
      final _jsonController = JsonRecyclerController(
      saveClosedHistory: false,
      showStandardJson: false,
      isExpanded: true,
    );

isExpanded - Sets whether the json tree is expanded by default

saveClosedHistory - The parameter defines whether the previously opened child tabs should be saved or not

showStandardJson - Will show json with curly braces

jsonKeyColor - Json key color in the tree

intColor - Set color of int parameters in the tree of json

doubleColor - Set color of double parameters in the tree of json

stringColor- Set color of string parameters in the tree of json

nullColor- Set color of null parameters in the tree of json

boolColor - Set color of bool parameters in the tree of json

objectColor - Set color of object parameters in the tree of json

standardJsonBackgroundColor - Set background color of widget

iconOpened - Custom icon for opening a node

iconClosed - Custom icon for closing a node

fontStyle - Set font style of text. By default, the inherited style used

fontWeight - Set font weight of text. By default FontWeight.bold

horizontalSpaceMultiplier- The distance by which the left child element will be offset from the parent

verticalOffset - The space by which the child element will be offset from the parent

additionalIndentChildElements - Additional indentation for aligning child elements depending on the size of the parent icon

  1. Add widget:

❗ Since the CrJsonRecyclerWidget has a builder in it, you must set the height or you will get an error

2.1 CrJsonRecyclerWidget:

     ...
     final data = <String, dynamic>{
         'integer': 1, 
         'string': 'test', 
     }
     ...
    CrJsonRecyclerWidget(
          ..
           json: data,
         ),
     ...

json - Parsed json

jsonController - Json controller to manage the json state

rootExpanded - Whether to expand the root nesting by default

Full implementation example:

      ...
      Expanded(
          child: CrJsonRecyclerWidget(
            json: json,
            jsonController: _jsonController,
            rootExpanded: true,
          ),
        ),
      ...

2.2 CrJsonRecyclerSliver:

     ...
     final data = <String, dynamic>{
         'integer': 1, 
         'string': 'test', 
     }
     ...
           CrJsonRecyclerSliver(
              ...
               json: json,
           ),
    ...

json - Parsed json

jsonController - Json controller to manage the json state

rootExpanded - Whether to expand the root nesting by default

Full implementation example:

        ...
        CustomScrollView(
              slivers: [
                    CrJsonRecyclerSliver(
                          jsonController: _jsonController,
                          json: json,
                          rootExpanded: true,
                    ),
              ],
          ),
        ...

카테고리

소스 저장소

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