搜尋套件、儲存庫與 APP 分類

ansicolor 封面
套件詳情v2.0.3

ansicolor

想為你的終端日誌增添一些色彩嗎?`ansicolor` 是一個支援 xterm-256 顏色的程式庫,可讓你變更文字的前景色與背景色。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
327萬
喜歡數
171
Pub 分數
160

安裝套件

flutter pub add ansicolor

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

ansicolor 是一個 Dart 庫,為終端輸出提供 xterm-256 顏色支援,讓開發者能夠自訂終端日誌中的文字前景色與背景色。它能無縫整合至跨平台的 Flutter 應用中,增強除錯可見度與日誌可讀性。此套件非常適合希望在不依賴外部工具的情況下為終端輸出增添視覺區別的開發者。透過簡潔語法,它直接在終端中支援廣泛的顏色與格式選項。

適用情境

  • 增強終端調試輸出
  • 顏色編碼日誌訊息
  • 提高 CLI 工具的可讀性
  • 在控制台應用程式中添加視覺反饋
  • 自定義命令列介面外觀

主要特色

  • 支援 xterm-256 顏色
  • 易於使用的顏色格式化
  • 跨平台終端支援
  • 前景/背景顏色的簡單API
  • 輕量且無依賴

適合對象

  • 開發 CLI 工具的開發者
  • 帶有控制台日誌記錄的 Flutter 應用
  • 需要視覺提示的除錯環境
  • 團隊改進日誌清晰度
  • 教育或教程專案

使用建議

  • 僅限終端輸出
  • 不適用於UI渲染
  • 需要支援 ANSI 顏色的終端
  • 在所有終端上可能無法一致地呈現
  • 除了代碼之外,無法進行執行時顏色自定義

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

ANSI / Xterm 256 color library for Dart

Feel like you're missing some color in your terminal programs? Use AnsiPen to add ANSI color codes to your log messages.

Easy to disable for production, just set color_disabled = true and all codes will be empty - no re-writing debug messages.

Note: color_disabled is a global variable for all pen colors.

Example

Note: Be mindful of contrasting colors. If you set "bright white" foreground and don't adjust the background, you'll have a bad time with lighter terminals.

Foreground to bright white with default background:

AnsiPen pen = AnsiPen()..white(bold: true);
print(pen("Bright white foreground") + " this text is default fg/bg");

Background as a peach, foreground as white:

AnsiPen pen = AnsiPen()..white()..rgb(r: 1.0, g: 0.8, b: 0.2, bg: true);
print(pen("White foreground with a peach background"));

Note

If color isn't working for you; try setting ansiColorDisabled = false;. We're relying on the stdio object to inform us of ANSI terminal support. Sometimes this is wrong.

Prior versions of this library just turned on color by default.

Rainbow Demo

If you want a specific color, you can call the xterm() with the index listed in the rainbow below. To show the rainbow on your own terminal, pub run examples/ansicolor.dart

alt tag

所屬分類

原始碼儲存庫

使用此套件的專案

所在榜單