搜尋套件、儲存庫與 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 輸出的使用者介面。

適用情境

  • 除錯 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

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。