### Basic Terminal Setup with Controller and View Source: https://pub.dev/packages/flterm Set up a TerminalController to manage terminal state and a TerminalView to render it. Connect the controller to your I/O streams. ```dart import 'package:flterm/flterm.dart'; final controller = TerminalController() ..onOutput = (bytes) => pty.write(bytes) ..onResize = (cols, rows) => pty.resize(cols, rows) ..onBell = playSound; ptyOutputStream.listen(controller.write); TerminalView( controller: controller, theme: TerminalTheme.dark(), ); ``` -------------------------------- ### Main Application Entry Point Source: https://pub.dev/packages/flterm/example This is the main entry point for the flterm example application. It handles web initialization and sets up the main application widget, allowing theme selection. ```dart import 'package:flterm/flterm.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'demo_page.dart'; import 'themes.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); if (kIsWeb) { await initializeForWeb( Uri.parse('assets/assets/libghostty-wasm32-freestanding.wasm'), ); } runApp(const _App()); } class _App extends StatefulWidget { const _App(); @override State<_App> createState() => _AppState(); } class _AppState extends State<_App> { var _themeIndex = 0; @override Widget build(BuildContext context) { final entry = TerminalThemes.all[_themeIndex]; return MaterialApp( debugShowCheckedModeBanner: false, theme: ThemeData.dark(), home: Scaffold( backgroundColor: entry.theme.background, body: SafeArea(child: DemoPage(theme: entry.theme)), floatingActionButton: Builder( builder: (innerContext) => FloatingActionButton( onPressed: () => _showThemePicker(innerContext), tooltip: 'Theme', backgroundColor: Colors.black54, foregroundColor: Colors.white, child: const Icon(Icons.palette), ), ), ), ); } Future _showThemePicker(BuildContext context) { final isLarge = MediaQuery.of(context).size.width >= 600; if (isLarge) { return showDialog( context: context, builder: (dialogContext) => Dialog( child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 360, maxHeight: 480), child: _ThemeList( currentIndex: _themeIndex, onSelect: (i) { setState(() => _themeIndex = i); Navigator.of(dialogContext).pop(); }, ), ), ), ); } return showModalBottomSheet( context: context, builder: (sheetContext) => SafeArea( child: _ThemeList( currentIndex: _themeIndex, onSelect: (i) { setState(() => _themeIndex = i); Navigator.of(sheetContext).pop(); }, ), ), ); } } class _ThemeList extends StatelessWidget { final int currentIndex; final ValueChanged onSelect; const _ThemeList({required this.currentIndex, required this.onSelect}); @override Widget build(BuildContext context) { return ListView.builder( shrinkWrap: true, itemCount: TerminalThemes.all.length, itemBuilder: (_, i) { final entry = TerminalThemes.all[i]; return ListTile( leading: Container( width: 36, height: 36, decoration: BoxDecoration( color: entry.theme.background, borderRadius: BorderRadius.circular(6), border: Border.all(color: entry.theme.foreground), ), ), title: Text(entry.name), selected: i == currentIndex, onTap: () => onSelect(i), ); }, ); } } ``` -------------------------------- ### flterm Dependency in pubspec.yaml Source: https://pub.dev/packages/flterm/install This is an example of how the flterm dependency will appear in your pubspec.yaml file after running `flutter pub add flterm`. ```yaml dependencies: flterm: ^0.0.4 ``` -------------------------------- ### Import flterm in Dart Code Source: https://pub.dev/packages/flterm/install Import the flterm package into your Dart files to start using its terminal widget functionality. ```dart import 'package:flterm/flterm.dart'; ``` -------------------------------- ### Initialize WASM Module for Web Source: https://pub.dev/packages/flterm On web platforms, initialize the wasm module once before mounting any terminal. This is crucial for web functionality. ```dart import 'package:flterm/flterm.dart'; import 'package:flutter/foundation.dart'; if (kIsWeb) { await initializeForWeb(Uri.parse('assets/libghostty.wasm')); } ``` -------------------------------- ### Configure Link Handling in TerminalView Source: https://pub.dev/packages/flterm Configure link detection and activation in the TerminalView. Built-in rules handle OSC 8 metadata, text URLs, and file paths. Custom activation callbacks can be provided. ```dart TerminalView( controller: controller, linkSettings: LinkSettings( onActivate: (link) { if (link.uri case final uri?) openUri(uri); if (link.file case final file?) openFile(file); }, ), ); ``` -------------------------------- ### Add Custom Link Rules Source: https://pub.dev/packages/flterm Add custom regex rules to the LinkSettings for project-specific selectors. Define rules with IDs and patterns, and handle their activation. ```dart TerminalView( controller: controller, linkSettings: LinkSettings( rules: [ .regex( id: 'issue', pattern: RegExp(r'#(\d+)'), ), ], onActivate: (link) { if (link.id == 'issue') openIssue(link.text.substring(1)); }, ), ); ``` -------------------------------- ### MIT License Source: https://pub.dev/packages/flterm/license The MIT License grants broad permissions for using, copying, modifying, merging, publishing, distributing, and sublicensing the software. It requires that the copyright notice and permission notice be included in all copies or substantial portions of the Software. The software is provided "as is" without warranty. ```plaintext MIT License Copyright (c) 2026 Elias Andualem Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ``` -------------------------------- ### Custom Terminal Theme Configuration Source: https://pub.dev/packages/flterm Create custom terminal themes by directly constructing a TerminalTheme object. This allows for detailed customization of the color palette, font family, font size, and cursor shape. ```dart TerminalView( controller: controller, theme: TerminalTheme( palette: ColorPalette( ansiColors: const [/* 16 ANSI colors */], background: const Color(0xFF1D1F21), foreground: const Color(0xFFC5C8C6), ), fontFamily: 'JetBrains Mono', fontSize: 14, cursor: const CursorTheme(shape: CursorShape.bar), ), ); ``` -------------------------------- ### Add flterm Dependency with Flutter Source: https://pub.dev/packages/flterm/install Run this command to add the flterm package as a dependency to your Flutter project. This command automatically updates your pubspec.yaml file. ```bash $ flutter pub add flterm ``` -------------------------------- ### Add flterm Dependency Source: https://pub.dev/packages/flterm Add the flterm package to your project's dependencies in pubspec.yaml. ```yaml dependencies: flterm: ^0.0.4 ``` -------------------------------- ### Programmatic Terminal Control Source: https://pub.dev/packages/flterm Control the terminal programmatically using the TerminalController. This includes sending text, managing selection, clipboard operations, and clearing the terminal. ```dart // I/O controller.sendText('ls -la\n'); // Selection controller.selectAll(); print(controller.selectedText()); // Clipboard controller.paste('hello'); // Reset controller.clear(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.