Terminal Library

Terminal Library for dart and flutter support cross platform with user friendly, so this will help you to integrated terminal to your app without any hastle

Demo

đŸ“šī¸ Docs

  1. Documentation
  2. Youtube
  3. Telegram Support Group
  4. Contact Developer (check social media or readme profile github)

đŸ”–ī¸ Features

  1. x đŸ“ąī¸ Cross Platform support (Device, Edge Severless functions)
  2. x đŸ“œī¸ Standarization Style Code
  3. x âŒ¨ī¸ Cli (Terminal for help you use this library or create project)
  4. x đŸ”Ĩī¸ Api (If you developer bot / userbot you can use this library without interact cli just add library and use đŸš€ī¸)
  5. đŸ§Šī¸ Customizable Extension (if you want add extension so you can more speed up on development)
  6. âœ¨ī¸ Pretty Information (user friendly for newbie)

â”ī¸ Fun Fact

This library work on everywhere platform (cli, server, web, gui) ignore flutter flag only pub.dev

đŸ“Ĩī¸ Install Library

  1. Dart
dart pub add terminal_library
  1. Flutter
flutter pub add terminal_library

? Who use this project / EXAMPLE PROJECT USE THIS LIBRARY

  1. General Studio Developer App

  2. General Bot App / General Automation App

  3. General Application

đŸš€ī¸ Quick Start

Example Quickstart script minimal for insight you or make you use this library because very simple

// ignore_for_file: empty_catches, non_constant_identifier_names
import 'dart:convert';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:general_lib/general_lib.dart';
import 'package:general_lib_flutter/extension/build_context.dart';
import 'package:general_lib_flutter/widget/widget.dart';
import 'package:terminal_library/pty_library/pty_library.dart';
import 'package:terminal_library/xterm_library/xterm.dart';

void main(List<String> args) {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const App());
}

class App extends StatelessWidget {
  static GeneralLibFlutterApp generalLibFlutterApp = GeneralLibFlutterApp();
  const App({super.key});
  @override
  Widget build(BuildContext context) {
    return GeneralLibFlutterAppMain(
      generalLibFlutterApp: generalLibFlutterApp,
      builder: (themeMode, lightTheme, darkTheme, widget) {
        Widget child = MaterialApp(
          theme: lightTheme,
          darkTheme: darkTheme,
          themeMode: themeMode,
          debugShowCheckedModeBanner: false,
          home: const MyApp(),
        );
        return child;
      },
    );
  }
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});
  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  TerminalLibraryFlutterController terminalLibraryFlutterController = TerminalLibraryFlutterController();
//  TerminalLibraryFlutterInputHandler terminalLibraryFlutterInputHandler = TerminalLibraryFlutterInputHandler;
  final TerminalLibraryFlutter terminalLibraryFlutter = TerminalLibraryFlutter(
    maxLines: 1000,
    // inputHandler:
  );
  late final PtyLibrary ptyLibrary;
  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      await refresh();
    });
  }

  @override
  void dispose() {
    ptyLibrary.kill();
    terminalLibraryFlutterController.dispose();
    super.dispose();
  }

  bool is_loading = false;
  Future<void> refresh() async {
    if (is_loading) {
      return;
    }
    setState(() {
      is_loading = true;
    });
    await Future(() async {
      await Future.delayed(Durations.short1);
      ptyLibrary = PtyLibrary.start(
        shell,
        columns: terminalLibraryFlutter.viewWidth,
        rows: terminalLibraryFlutter.viewHeight,
      );
      ptyLibrary.output.listen((event) {
        if (event.isNotEmpty) {
          try {
            terminalLibraryFlutter.write(utf8.decode(event, allowMalformed: true));
          } catch (e) {}
        }
      });
      terminalLibraryFlutter.onOutput = (String value) {
        if (value.isNotEmpty) {
          try {
            ptyLibrary.write(utf8.encode(value));
          } catch (e) {}
        }
      };
      terminalLibraryFlutter.onResize = (w, h, pw, ph) {
        ptyLibrary.resize(h, w);
      };
      terminalLibraryFlutter.buffer.clear();
      terminalLibraryFlutter.buffer.setCursor(0, 0);
      terminalLibraryFlutter.textInput("clear");
      terminalLibraryFlutter.keyInput(TerminalLibraryFlutterKey.enter);
      setState(() {});
    });
    setState(() {
      is_loading = false;
    });
  }

  @override
  Widget build(BuildContext context) {
    if (is_loading) {
      return Scaffold(
        body: Center(
          child: CircularProgressIndicator(
            color: context.theme.indicatorColor,
          ),
        ),
      );
    }
    return Scaffold(
      appBar: AppBar(
        title: const Text("Terminal Library:"),
      ),
      body: TerminalLibraryFlutterViewWidget(
        terminalLibraryFlutter,
        controller: terminalLibraryFlutterController,
        autofocus: true,
        backgroundOpacity: 0,
        simulateScroll: true,
        padding: const EdgeInsets.all(5),
        alwaysShowCursor: true,
        deleteDetection: Dart.isMobile,
      ),
    );
  }

  static String get shell {
    if (Platform.isMacOS || Platform.isLinux) {
      return Platform.environment['SHELL'] ?? 'bash';
    }
    if (Platform.isWindows) {
      return 'cmd.exe';
    }
    return 'sh';
  }
}

Libraries

isolate/io
isolate/isolate
isolate/none
pty_library/base
pty_library/io
pty_library/none
pty_library/pty_library
pty_library/src/terminal_pty_bindings_generated
ssh_library/core/algorithm/ssh_cipher_type
ssh_library/core/algorithm/ssh_hostkey_type
ssh_library/core/algorithm/ssh_kex_type
ssh_library/core/algorithm/ssh_mac_type
ssh_library/core/hostkey/hostkey_ecdsa
ssh_library/core/hostkey/hostkey_ed25519
ssh_library/core/hostkey/hostkey_rsa
ssh_library/core/http/http_client
ssh_library/core/http/http_content_type
ssh_library/core/http/http_exception
ssh_library/core/http/http_headers
ssh_library/core/http/line_decoder
ssh_library/core/kex/kex_dh
ssh_library/core/kex/kex_nist
ssh_library/core/kex/kex_x25519
ssh_library/core/message/msg_channel
ssh_library/core/message/msg_debug
ssh_library/core/message/msg_disconnect
ssh_library/core/message/msg_ignore
ssh_library/core/message/msg_kex
ssh_library/core/message/msg_kex_dh
ssh_library/core/message/msg_kex_ecdh
ssh_library/core/message/msg_request
ssh_library/core/message/msg_service
ssh_library/core/message/msg_userauth
ssh_library/core/sftp/sftp_client
ssh_library/core/sftp/sftp_errors
ssh_library/core/sftp/sftp_file_attrs
ssh_library/core/sftp/sftp_file_open_mode
ssh_library/core/sftp/sftp_name
ssh_library/core/sftp/sftp_packet
ssh_library/core/sftp/sftp_packet_ext
ssh_library/core/sftp/sftp_request_id
ssh_library/core/sftp/sftp_status_code
ssh_library/core/sftp/sftp_statvfs
ssh_library/core/sftp/sftp_stream_io
ssh_library/core/socket/ssh_socket
ssh_library/core/socket/ssh_socket_io
ssh_library/core/socket/ssh_socket_js
ssh_library/core/ssh_algorithm
ssh_library/core/ssh_channel
ssh_library/core/ssh_channel_id
ssh_library/core/ssh_client
ssh_library/core/ssh_errors
ssh_library/core/ssh_forward
ssh_library/core/ssh_hostkey
ssh_library/core/ssh_keepalive
ssh_library/core/ssh_kex
ssh_library/core/ssh_kex_utils
ssh_library/core/ssh_key_pair
ssh_library/core/ssh_message
ssh_library/core/ssh_packet
ssh_library/core/ssh_pem
ssh_library/core/ssh_session
ssh_library/core/ssh_signal
ssh_library/core/ssh_transport
ssh_library/core/ssh_userauth
ssh_library/core/utils/async_queue
ssh_library/core/utils/bcrypt
ssh_library/core/utils/bigint
ssh_library/core/utils/chunk_buffer
ssh_library/core/utils/cipher_ext
ssh_library/core/utils/int
ssh_library/core/utils/list
ssh_library/core/utils/stream
ssh_library/core/utils/string
ssh_library/core/utils/utf8
ssh_library/ssh_library
terminal_library
terminal_library_core
xterm_library/core
xterm_library/core/base/disposable
xterm_library/core/base/event
xterm_library/core/base/observable
xterm_library/core/core/buffer/buffer
xterm_library/core/core/buffer/cell_flags
xterm_library/core/core/buffer/cell_offset
xterm_library/core/core/buffer/line
xterm_library/core/core/buffer/range
xterm_library/core/core/buffer/range_block
xterm_library/core/core/buffer/range_line
xterm_library/core/core/buffer/segment
xterm_library/core/core/cell
xterm_library/core/core/charset
xterm_library/core/core/color
xterm_library/core/core/cursor
xterm_library/core/core/escape/emitter
xterm_library/core/core/escape/handler
xterm_library/core/core/escape/parser
xterm_library/core/core/input/handler
xterm_library/core/core/input/keys
xterm_library/core/core/input/keytab/keytab
xterm_library/core/core/input/keytab/keytab_default
xterm_library/core/core/input/keytab/keytab_escape
xterm_library/core/core/input/keytab/keytab_parse
xterm_library/core/core/input/keytab/keytab_record
xterm_library/core/core/input/keytab/keytab_token
xterm_library/core/core/input/keytab/qt_keyname
xterm_library/core/core/mouse/button
xterm_library/core/core/mouse/button_state
xterm_library/core/core/mouse/handler
xterm_library/core/core/mouse/mode
xterm_library/core/core/mouse/reporter
xterm_library/core/core/platform
xterm_library/core/core/reflow
xterm_library/core/core/snapshot
xterm_library/core/core/state
xterm_library/core/core/tabs
xterm_library/core/terminal
xterm_library/core/terminal_view
xterm_library/core/ui/char_metrics
xterm_library/core/ui/controller
xterm_library/core/ui/cursor_type
xterm_library/core/ui/custom_text_edit
xterm_library/core/ui/gesture/gesture_detector
xterm_library/core/ui/gesture/gesture_handler
xterm_library/core/ui/infinite_scroll_view
xterm_library/core/ui/input_map
xterm_library/core/ui/keyboard_listener
xterm_library/core/ui/keyboard_visibility
xterm_library/core/ui/painter
xterm_library/core/ui/palette_builder
xterm_library/core/ui/paragraph_cache
xterm_library/core/ui/pointer_input
xterm_library/core/ui/render
xterm_library/core/ui/scroll_handler
xterm_library/core/ui/selection_mode
xterm_library/core/ui/shortcut/actions
xterm_library/core/ui/shortcut/shortcuts
xterm_library/core/ui/terminal_size
xterm_library/core/ui/terminal_text_style
xterm_library/core/ui/terminal_theme
xterm_library/core/ui/themes
xterm_library/core/utils/ascii
xterm_library/core/utils/byte_consumer
xterm_library/core/utils/char_code
xterm_library/core/utils/circular_buffer
xterm_library/core/utils/debugger
xterm_library/core/utils/debugger_view
xterm_library/core/utils/hash_values
xterm_library/core/utils/lookup_table
xterm_library/core/utils/unicode_v11
xterm_library/suggestion
xterm_library/ui
xterm_library/utils
xterm_library/xterm
xterm_library/zmodem