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

tint 封面
套件詳情v2.0.1

tint

一個作為 `String` 擴展的終端字串樣式庫。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
50.6萬
喜歡數
41
Pub 分數
150

安裝套件

flutter pub add tint

套件介紹

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

Tint 是一個 Flutter/Dart 套件,為 String 類別新增終端機字串樣式功能。它讓開發者能輕鬆地為控制台或 CLI 應用程式中的文字輸出套用顏色、樣式與格式。透過簡單語法,使用者可在後台使用 ANSI 轉義碼來強調日誌、除錯訊息或互動式提示。此函式庫支援所有主要平台,包含 Android、iOS、Web、macOS、Windows 與 Linux,非常適合跨平台命令列工具。Tint 簡化了終端美學,無需手動處理轉義序列。

適用情境

  • 控制台彩色日誌
  • CLI 使用者介面增強功能
  • 除錯訊息強調
  • 基於終端的儀表板
  • 跨平台終端輸出
  • 互動式命令列應用程式

主要特色

  • String 擴展用於樣式設定
  • ANSI 轉義碼支援
  • Platform-agnostic
  • 簡單 API
  • 顏色與樣式自訂
  • 內建預設

適合對象

  • 開發命令列工具的開發者
  • 具有主控台輸出的Flutter應用程式
  • 日誌和除錯工具
  • 跨平台終端應用程式
  • 教育或演示專案

使用建議

  • 限制為終端輸出
  • 無執行時樣式變更
  • 依賴終端支援
  • 不適用於UI渲染
  • 最少文件
  • 無主題系統

原始 README

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

Tint

Tint is a library for terminal string styling extended upon Dart's String type.


Overview

// tint.dart
import 'package:tint/tint.dart';

void main() {
  print('underlined blue text on white background'
      .underline()
      .blue()
      .onWhite());
}

The snippet will produce an underlined blue text on a white background once you run it inside a terminal.

The example at example/main.dart file contains examples for all APIs. Try running it and you'll get something this.


Installation

Install the latest version of tint as a dependency as shown in pub.dev.


API Documentation

For reference, all of the available APIs will be used as an example in the example/main.dart file.


Foreground Colors

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • brightBlack or gray or grey
  • brightRed
  • brightGreen
  • brightYellow
  • brightBlue
  • brightMagenta
  • brightCyan
  • brightWhite

Background Colors

  • onBlack
  • onRed
  • onGreen
  • onYellow
  • onBlue
  • onMagenta
  • onCyan
  • onWhite
  • onBrightBlack or onGray or onGrey
  • onBrightRed
  • onBrightGreen
  • onBrightYellow
  • onBrightBlue
  • onBrightMagenta
  • onBrightCyan
  • onBrightWhite

Attributes

  • bold
  • dim
  • italic
  • underline
  • blink
  • inverse
  • strikethrough

Dynamic Colors

  • rgb({int r, int g, int b})
  • onRgb({int r, int g, int b})

Utilities

  • reset (reset the color using ANSI code)
  • strip (remove all ANSI codes)

Alternatives

Tint is an alternative to,


Acknowledgement

Node's chalk is the library that inspired tint the most but the naming of the APIs such as onMagenta instead of bgMagenta and certain aspects of the library are mostly influenced by the console crate from Rust. The ansicolor and ansi_styles packages also provide the same functionality but with a different delivery for the usage. But I personally find extension methods syntactically more fun to use.

所屬分類

原始碼儲存庫

使用此套件的專案