ContextMenu
Open menu commands from secondary click, long press, or the keyboard context-menu key.
Open menu commands from secondary click, long press, or the keyboard context-menu key.
Contract
| Axis | Contract |
|---|---|
| Presentation | Without a scope, TRFlutterContextMenuPresenter draws Tinyrack menu components in the app overlay. Every platform the native presenter cannot serve — mobile, web, and a desktop build without the plugin registered — falls back to it, so no surface is left with an unstyled menu. |
| What a system menu drops | A system menu takes a platform bitmap rather than an IconData, so TRMenuActionElement.icon shows only in the Flutter presentation. The system also owns dismissal, so TRContextMenuController.close does nothing once a native menu is up. Titles, shortcuts, check marks, disabled entries, and submenus carry across both. |
| Opening from code | A surface that consumes the secondary pointer button itself, such as a terminal reporting mouse events, passes a TRContextMenuController and calls openAt with a global position. TRTerminalView.contextMenuItems does exactly this. |
The default constructor takes widgets and always draws them with Flutter. TRContextMenu.items describes the menu as TRMenuElements instead, which lets the installed TRContextMenuPresenter hand it to the operating system. Install TRNativeContextMenuPresenter through TRContextMenuPresenterScope at the composition root to get the platform menu on Linux, macOS, and Windows.
Install
Add the package, then import its public library.
flutter pub add tinyrack_uiimport 'package:tinyrack_ui/tinyrack_ui.dart';Playground
Usage
import 'package:material_ui/material_ui.dart';
import 'package:tinyrack_ui/tinyrack_ui.dart';
TRContextMenu.items(
items: [TRMenuActionElement(id: 'open', title: 'Open', onPressed: open)],
child: card,
)API
ContextMenu preserves native Flutter state and callbacks while applying Tinyrack token defaults.