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

源码仓库

使用此插件的项目