RadarTUI: A Flutter-Inspired TUI Framework for Dart

License: MIT Platform: Dart Style: effective_dart

RadarTUI is a Flutter-style framework for building beautiful and responsive Terminal User Interfaces (TUIs) using Dart. Easily develop complex terminal applications with a declarative widget paradigm.


🎯 Key Features

  • ✨ Declarative UI: A Flutter-like widget tree structure where the UI automatically updates when the state changes.
  • πŸ“¦ Rich Widget Library: Provides essential layout and UI widgets like Row, Column, Text, Container, Button, TextField, and more.
  • ⚑️ Efficient Rendering: Intelligent diff-based terminal rendering optimization that only redraws the parts that have changed.
  • ⌨️ Flexible Input Handling: Easily handle keyboard events and interact with the application state.
  • 🎨 Flexible Layout System: Easily configure complex UIs with a powerful Flexbox-based layout widget.
  • 🧭 Intuitive State Management: Clear and predictable state management through StatelessWidget and StatefulWidget patterns.

πŸ—οΈ Architecture

RadarTUI follows a layered architecture inspired by Flutter. Each layer has a clearly defined role, enhancing the code's maintainability and scalability.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     Application Layer    β”‚ (User Applications)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚       Widgets Layer      β”‚ (Declarative UI Widgets)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚      Scheduler Layer     β”‚ (Frame Scheduling & Lifecycle)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚      Rendering Layer     β”‚ (Layout & Painting)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚       Services Layer     β”‚ (Terminal Control, I/O)
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚      Foundation Layer    β”‚ (Basic Data Types)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

For more detailed architecture information, please refer to the AGENTS.md document.

πŸš€ Getting Started

1. Add Dependency

Add RadarTUI to your pubspec.yaml file.

dependencies:
  radartui:
    path: ../ # Or specify the pub.dev version

2. Basic Example Code

Here is a simple counter application example.

import 'package:radartui/radartui.dart';

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

class CounterApp extends StatefulWidget {
  const CounterApp({Key? key}) : super(key: key);

  @override
  State<CounterApp> createState() => _CounterAppState();
}

class _CounterAppState extends State<CounterApp> {
  int _counter = 0;
  StreamSubscription? _subscription;

  @override
  void initState() {
    super.initState();
    _subscription = SchedulerBinding.instance.keyboard.keyEvents.listen((event) {
      if (event.key == 'q') {
        shutdown();
      } else {
        setState(() {
          _counter++;
        });
      }
    });
  }

  @override
  void dispose() {
    _subscription?.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Text(
        'Press any key to increment the counter: $_counter
Press 'q' to quit.',
        style: const TextStyle(color: AnsiColor.green),
      ),
    );
  }
}

πŸ“¦ How to Run Examples

Check out the various examples included in the project to see the features of RadarTUI.

  1. Navigate to the example directory.

    cd example
    
  2. Install dependencies.

    dart pub get
    
  3. Run the desired example. (main.dart provides a menu to select various examples)

    dart run
    

πŸ—ΊοΈ Roadmap

RadarTUI is continuously evolving. Many core features are already implemented:

βœ… Implemented

  • Animation System: Basic animation support with indicators
  • Focus Management System: Keyboard navigation and focus control between widgets
  • Theme System: Centralized management of colors and styles for the entire application
  • Widget Testing Framework: Testing utilities for TUI applications
  • Advanced Layout Widgets: Grid, Stack, ListView, Wrap, IndexedStack
  • Rich Widgets: DataTable, TabBar/TabBarView, DropdownButton, Icon
  • Input Handling: Shortcuts/Actions for keyboard shortcuts

🚧 Planned

  • Enhanced Animation System: Smooth visual transitions for state changes
  • Mouse Support: Optional mouse event handling
  • More Widgets: Additional Flutter-compatible widgets

🀝 Contributing

Contributions to RadarTUI are welcome! Bug reports, feature suggestions, code contributions, and any other form of participation are appreciated.

Before you start contributing, reading the AGENTS.md architecture document will be very helpful in understanding the project structure.

πŸ“œ License

RadarTUI is distributed under the MIT License.

Libraries

radartui
RadarTUI - A Flutter-style TUI framework for Dart.
radartui_test