搜索插件、代码仓与 APP 分类

colored_json 封面
插件详情v1.1.2

colored_json

一个将 JSON 字符串转换为可自定义的 Flutter 小部件的包。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
3510
喜欢数
27
Pub 分数
160

安装插件

flutter pub add colored_json

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可将 JSON 字符串转换为视觉增强且可自定义的控件,并支持语法高亮。它使开发者能够在应用中以清晰美观的格式显示结构化 JSON 数据。该控件支持对键、值和括号等不同 JSON 元素进行颜色自定义,从而在调试或数据展示时提升可读性。非常适合开发工具、仪表板或任何需要格式化 JSON 输出的 UI。

适合场景

  • 调试 JSON 响应
  • 在应用程序中显示 API 数据
  • 增强开发者工具界面
  • 可视化配置文件
  • 实时数据检查
  • 教育类应用程序内容展示

主要特点

  • JSON 语法高亮
  • 可自定义的颜色和样式
  • 与 Flutter 小部件的轻松集成
  • 支持所有主要平台
  • 轻量级且快速渲染
  • 可配置的缩进和间距

适合对象

  • Flutter 开发者
  • 调试工具
  • API 测试接口
  • 学习应用
  • 与结构化数据一起工作的UI设计师

使用建议

  • 可能会影响非常大的 JSON 的性能
  • 仅限静态JSON显示
  • 需要手动输入字符串或解析
  • 不适用于动态 JSON 编辑
  • 颜色主题需要显式设置
  • 最佳用于非生产环境的调试视图

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Colored JSON

Convert JSON string into customizable widget.

Getting Started

ColoredJson is a stateless widget that produces a structured view of JSON string provided. It can be used like any other flutter widget. It's fully customizable where you can set different colors to different datatypes including colon, comma and brackets. Set indent length. Use text style of your choice. You can also change the background color.

Defaut View Customised View 1 Customised View 2
Default View Customized View 1 Customized View 2

Usage

  • Pass a JSON string to the data parameter of ColoredJson Widget
Simple Usage
const String responseBody = '''
{
  'id' : 1,
  'name' : 'Colored Json',
  'isFlutterAwesome' : true,
}
''';

ColoredJson(
 data: responseBody,
)

Full Usage
final dartMap = {
  "id": 24,
  "name": "Manthan Khandale",
  "score": 7.6,
  "socials": null,
  "hobbies": [
    "Music",
    "Filmmaking",
  ],
  "isFlutterCool": true,
};

ColoredJson(
 data: jsonEncode(dartMap),
 indentLength: 5,
 keyColor: Colors.green,
 backgroundColor: Colors.black,
 boolColor: Colors.white,
 nullColor: Colors.redAccent,
 stringColor: Colors.cyan,
 curlyBracketColor: Colors.yellow,
 doubleColor: Colors.deepOrange,
 squareBracketColor: Colors.amber,
 commaColor: Colors.yellow,
 colonColor: Colors.purple,
 intColor: Colors.lime,
 textStyle: const TextStyle(
  fontSize: 20,
  letterSpacing: 2,
  ),
 )
Parameter Info
data (required) A JSON string to be formatted
keyColor Color of Json Key
intColor Color of integer type value
doubleColor Color of decimal type value
stringColor Color of string type value
boolColor Color of boolean type value
nullColor Color of null type value
curlyBracketColor Color of curly brackets {}
squareBracketColor Color of square brackets []
commaColor Color of comma ( , )
colonColor Color of colon ( : )
backgroundColor Background color of widget
textStyle Textstyle of texts in the widget
indentLength Indent length

Upcoming Tasks

  • Code shrink feature
  • Add Inner Spacing parameter
  • Add tests

所属分类

源码仓库

使用此插件的项目

暂无相关数据。