搜索插件、代码仓与 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.

所属分类

源码仓库

使用此插件的项目