nocterm 0.3.2 copy "nocterm: ^0.3.2" to clipboard
nocterm: ^0.3.2 copied to clipboard

A Flutter-like framework for terminal UIs.

Nocterm

CI Pub Version License Documentation

Docs | pub.dev | Quick Start

If you know Flutter, you know Nocterm. Build terminal UIs with the same patterns—StatefulComponent, setState(), Column, Row, and hot reload.

Nocterm Example

Note: Nocterm is in early development (0.3.2). APIs may change.

Installation #

dependencies:
  nocterm: ^0.3.2

Quick Start #

import 'package:nocterm/nocterm.dart';

void main() {
  runApp(const Counter());
}

class Counter extends StatefulComponent {
  const Counter({super.key});

  @override
  State<Counter> createState() => _CounterState();
}

class _CounterState extends State<Counter> {
  int _count = 0;

  @override
  Component build(BuildContext context) {
    return Focusable(
      focused: true,
      onKeyEvent: (event) {
        if (event.logicalKey == LogicalKey.space) {
          setState(() => _count++);
          return true;
        }
        return false;
      },
      child: Center(
        child: Text('Count: $_count'),
      ),
    );
  }
}

Run with hot reload:

dart --enable-vm-service your_app.dart

Testing #

Test your TUI components just like Flutter widgets:

await testNocterm('counter test', (tester) async {
  await tester.pumpComponent(Counter());
  await tester.sendKey(LogicalKey.space);

  expect(tester.terminalState, containsText('Count: 1'));
});

Documentation #

See the full documentation for guides on components, state management, testing, and more.

Contributing #

Git Hooks #

We use hooksman to manage git hooks. To install the hooks, run:

dart run hooksman

License #

MIT