Skip to main content

terminal_ui 0.2.1 copy "terminal_ui: ^0.2.1" to clipboard
terminal_ui: ^0.2.1 copied to clipboard

Terminal widgets for Flutter: an app drawn on a character grid, with box-drawn panes, bracketed buttons, inverse selection and keys beside every action.

terminal_ui #

Terminal widgets for Flutter: an app drawn on a character grid, with box-drawn panes, bracketed buttons, inverse selection and keys beside every action.

slipway, the example deploy console: home at a desk by night beside a new deploy on a phone on paper

Live gallery · API reference · All the looks

Getting started #

flutter pub add terminal_ui material_ui

Load the bundled monospace fonts before the first frame. Wrap the app in TermTheme to set its palette and grid. This example uses material_ui for the app shell.

import 'package:material_ui/material_ui.dart';
import 'package:terminal_ui/terminal_ui.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await termLoadFonts();
  runApp(
    MaterialApp(
      // Your routes change screens as a terminal does (see Page motion).
      theme: ThemeData(
        pageTransitionsTheme: const PageTransitionsTheme(
          builders: termPageTransitions,
        ),
      ),
      builder: (context, child) =>
          TermTheme(data: TermThemeData.dark(), child: child!),
      home: const Deploy(),
    ),
  );
}

class Deploy extends StatelessWidget {
  const Deploy({super.key});

  @override
  Widget build(BuildContext context) => TermPane(
    title: 'new deploy',
    child: TermButton.filled(label: 'deploy', onPressed: () {}),
  );
}

Page motion #

Terminal routes open with a brief fade and pop with a cut. Tabs and side panes switch in place. Set pageTransitionsTheme on the app's ThemeData, as in the example above, to give routes pushed by its navigator the same transition. Alternatively, push a TermPageRoute to use the transition for one route.

The iOS transition supports the swipe from the leading edge. On Android, Back first dismisses an open menu, list or popover.

The look #

Flutter widgets drawn the way a well-made terminal program draws itself: every size whole character cells, panes in box-drawing lines with their titles cut into the top line, buttons in brackets, the chosen row in inverse video, and the key for every action written beside it. A sixteen colour palette in a night and a paper preset, a monochrome theme, and everything you need to reach it by touch, pointer, keyboard and screen reader.

┌─ runs ─────────────────────────────── 3 ─┐
│ ⠹ #1482 atlas-api                    now │
│ ✗ #1481 atlas-api                 3m 02s │
│ ✓ #911  web-console               4m 31s │
└─ ⏎ open ─────────────────────────────────┘
  [ cancel ] esc   [ deploy ] ⏎

Screens #

The example app, slipway, is a made-up deploy console built only from these widgets.

The runs, the failing run and its log tiled at a desk, paper preset

The command palette over the runs, night preset

A run's change as a side-by-side diff, paper preset

One failing run on a phone, night preset

What's inside #

Every component an ordinary app expects, each drawn in the grid and each on ui_core's behaviour where it has one: 84 of the 89 in ui_core's inventory (termInventory lists them; the five it leaves out would move the structure or leave the grid).

  • Panes (TermPane, TermPane.list): the look's card, group and window. The line doubles in the accent while focus is inside.
  • Actions: TermButton (and .filled), TermIconButton, TermButtonGroup, TermToggleGroup (a segmented control too), TermSplitButton, TermLink, TermKey.
  • Fields: TermTextField (a text area with lines:, add-ons with prefixText/suffixText), TermPasswordField, TermOtpField, TermNumberField, TermSelect, TermCombobox, TermTagInput, TermFileField, TermDatePicker, TermDateRangePicker, TermTimeField, TermCalendar, TermColorPicker.
  • Choices and ranges: TermCheckbox, TermRadio, TermSwitch, TermChip, TermSlider, TermRangeSlider, TermRating, TermMeter.
  • Rows and collections: TermListTile, TermSectionHeader, TermTable, TermDataTable, TermTree, TermDisclosure, TermReorderableList, TermPullToRefresh, TermTimeline, TermDescriptionList, TermTag, TermBadge, TermAvatar, TermMedia, TermDivider, TermScrollArea, TermSplitView.
  • Navigation: TermScaffold (a phone's window list, a tablet's rail, a desk's side pane), TermTopBar, TermTabBar, TermNavigationBar, TermNavigationRail, TermSideBar, TermStatusLine, TermBreadcrumb, TermPagination, TermPageDots, TermSteps, TermMenuBar and TermCommandPalette.
  • Over the screen: TermDialog, the y/N question showTermConfirmDialog (with a typed guard for destroying things), showTermSheet, showTermSideSheet, showTermActionSheet, TermPopover, TermHoverCard, TermTooltip, TermMenu, TermContextMenu (a right click, a long press or Shift+F10), toasts through TermToaster, TermBanner, and screens through TermPageRoute. A screen change is a cut or a very short fade and a menu opens where it stays: nothing travels into place.
  • Working and states: TermSpinner (braille), TermProgressBar (blocks in eighths of a cell), TermSkeleton, TermStatusView, TermEmptyState, TermCaret.
  • Charts: TermLineChart and TermAreaChart in braille dots, TermBarChart and TermSparkline in blocks.
  • Foundations: TermThemeData (.dark(), .light(), .monochrome(), .from(palette)), TermPalette, TermAnsi, TermGrid, TermFace, and termKeyLabel for writing shortcuts.

Make it yours #

Every part takes a style: (a TermStyle) over its slot in TermThemeData: one slot a part, and one a kind of button. A style sets colours (and a weight, on parts with words of their own); sizes stay whole cells and lines, so a style can't take the look off its grid.

final base = TermThemeData.dark(
  // Your brand's colour, pulled until it reads at 4.5:1 on the background.
  accent: termReadable(const Color(0xFF0A7D4F), on: TermPalette.night.background),
);

final theme = base.copyWith(
  // Every primary button.
  filledButtonStyle: TermStyle(
    fill: WidgetStatePropertyAll(TermAnsi.magenta.of(base.palette)),
    edge: WidgetStatePropertyAll(TermAnsi.magenta.of(base.palette)),
  ),
);

// One button.
TermButton(
  label: 'roll back',
  onPressed: rollBack,
  style: TermStyle(
    foreground: WidgetStatePropertyAll(theme.warning),
    edge: WidgetStatePropertyAll(theme.warning),
  ),
);

A brand colour that can't read at 4.5:1 asserts in debug and names termReadable. TermThemeData also takes a face (a monospace face and its advance together) and a stroke (box drawing's light or heavy line); AnimatedTermTheme animates a change. The painters and faces the parts are drawn with (TermFramePainter, TermBracketFace, TermCellFace, TermMenuRow, TermSpring, …) are public, for a part of your own in the look.

The pointer over a part changes nothing by default: a terminal has no hover, and the cursor already says what presses. Only the lit row of an open menu or select follows it. Every style still sees WidgetState.hovered, so a hover is one line away:

TermThemeData.dark().copyWith(
  listTileStyle: TermStyle(
    fill: WidgetStateProperty.fromMap({
      WidgetState.hovered: TermAnsi.blue.of(TermPalette.night).withValues(alpha: 0.2),
    }),
  ),
);

The grid #

Every width is whole cells and every height whole lines: a 15 px face on a 9 × 24 cell. The text scale grows the grid, so at 200% a cell is twice the size and the lattice still holds. A control's target is one line under a pointer and two under a finger.

Accessibility #

Box-drawing, braille and block glyphs are painted, not typed, and a screen reader hears what they mean (a status's word, a spinner's "loading", a bar's percentage) instead. Inverse selection is announced as selected. The spinners and the caret hold still under Reduce Motion. Every tone has a glyph (✓ ✗ ! i), so nothing is said by colour alone; the monochrome theme proves it.

Tab visits a tab bar or navigation group once. Use the arrow keys to move between destinations and F6 to switch between navigation and the page. Dialogs and sheets keep focus inside and return it to the opener on close. On line and area charts, the arrows inspect data points. Ratings accept arrow and number keys. Screen readers announce shortcuts such as ^K as “Ctrl+K”.

The navigation bar wraps its labeled destinations when space is tight. A selected date range uses extra lines when necessary so both dates stay visible at larger text sizes.

Fonts #

JetBrains Mono (SIL Open Font License 1.1) for the words, and Liberation Mono (SIL Open Font License 1.1) for Hebrew, with the same advance so the grid holds right to left. Their licences ship in assets/fonts/LICENSES/.

1
likes
160
points
0
downloads
screenshot

Documentation

API reference

Publisher

verified publisherwenkaifan.com

Weekly Downloads

Terminal widgets for Flutter: an app drawn on a character grid, with box-drawn panes, bracketed buttons, inverse selection and keys beside every action.

Homepage
Repository (GitHub)
View/report issues

Topics

#design-system #widget #ui #theme #terminal

License

BSD-3-Clause (license)

Dependencies

flutter, material_ui, ui_core

More

Packages that depend on terminal_ui