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

套件詳情v4.1.0

console

一個用於終端應用程式的常見功能庫,包括顏色格式化、鍵盤輸入和進度條。

AndroidiOSmacOSWindowsLinux
近 30 天下載
38萬
喜歡數
70
Pub 分數
120

安裝套件

flutter pub add console

套件介紹

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

console 套件為在 Dart 與 Flutter 中建構命令列應用程式提供了基本工具。它提供彩色文字輸出、互動式鍵盤輸入處理以及進度條視覺化等功能。專為 CLI 開發者設計,透過乾淨的跨平台 API 簡化終端互動。該套件支援多個平台,包括 Android、iOS、macOS、Windows 和 Linux,非常適合在 UI 環境外執行的工具。其輕量級特性和對開發者體驗的關注,使其成為腳本編寫、自動化與基於控制台工作流程的理想選擇。

適用情境

  • 構建 CLI 工具
  • 互動式終端應用程式
  • 腳本中的進度追蹤
  • 彩色日誌
  • 命令列用戶輸入處理

主要特色

  • 顏色格式支援
  • 鍵盤輸入工具
  • 進度條組件
  • 跨平台相容性
  • 簡單的 API 設計

適合對象

  • CLI 開發者
  • 腳本工具
  • 自動化工作流
  • 基於終端的介面
  • Dart/Flutter 控制台應用

使用建議

  • 僅限主控台環境
  • 無GUI整合
  • 需要終端存取
  • 平台特定的行為是可能的
  • 不適用於網頁或行動UI

原始 README

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

Console

A high-level console library.

Features

  • Console Colors (ANSI)
  • Icons (UTF-8)
  • Keyboard Capture
  • Experimental Clipboard Support
  • Progress Bars
  • Flexible Prompts
  • Shell Prompts
  • Choosers
  • Fancy Formatting
  • Loading Bars
  • Timer (like pub's timer)
  • Fancy Trees (like the npm dependency trees)
  • Simple Unit Testing

Usage

This library does not work in browsers (for a hopefully obvious reason).

import "package:console/console.dart";

void main() {
  // Initialize the Console. Throws an exception if advanced terminal features are not supported.
  Console.init();
  
  // Use the library...
}

Unit Testing

You can test the output produced by this library (and thus your own project that uses this library). Here is an example:

import "package:test/test.dart";
import "package:console/console.dart";

void main() {
  final output = new BufferConsoleAdapter();

  setUpAll(() => Console.adapter = output);

  // Clear output between test runs
  setUp(() => output.clear());

  group('base functions', () {
    test('centerCursor', () {
      Console.centerCursor();
      expect(output.toString(), '${Console.ANSI_ESCAPE}10;40H');
    });
  });
}

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案